SpringSecurity报错There is no PasswordEncoder mapped for the id “null“

解决方法:自定义加密方式,实现PasswordEncoder接口
1.添加一个自定义类:

//设置信息明文传输
public class MyPasswordEncoder implements PasswordEncoder {
    @Override
    public String encode(CharSequence charSequence) {
        return charSequence.toString();
    }

    @Override
    public boolean matches(CharSequence charSequence, String s) {
        return s.equals(charSequence.toString());
    }
}
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
        auth.inMemoryAuthentication()
                .passwordEncoder(new MyPasswordEncoder())
                .withUser("zhangsan").password("123").roles("VIP1","VIP2");
    }

你可能感兴趣的:(Spring,java,spring,spring,boot)