欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

spring boot使用spring boot security登陆时报错There is no PasswordEncoder mapped for the id "null"

程序员文章站 2022-04-14 22:42:45
...

出现该错误是因为密码加密问题,需要在securityConfig配置类中配置

    @Autowired
    UserDetailsService userDetailsService;
    @Autowired
    public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception{
        auth.userDetailsService(userDetailsService()).passwordEncoder(passwordEncoder());
    }
    @Bean
    public static NoOpPasswordEncoder passwordEncoder() {
        return (NoOpPasswordEncoder) NoOpPasswordEncoder.getInstance();
    }
spring boot使用spring boot security登陆时报错There is no PasswordEncoder mapped for the id "null"