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

Spring Security 无法登陆,报错:There is no PasswordEncoder mapped for the id “null”

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

Spring Security 无法登陆,报如下错误!

 auth.inMemoryAuthentication()
                .withUser("java1234")
                .password("123456")
                .roles("ADMIN");

Spring Security 无法登陆,报错:There is no PasswordEncoder mapped for the id “null”

使用如下代码就解决ok!

auth.inMemoryAuthentication().passwordEncoder(new BCryptPasswordEncoder()).withUser("java1234").password(new BCryptPasswordEncoder().encode("123456")).roles("ADMIN");

 

参考自:https://blog.csdn.net/canon_in_d_major/article/details/79675033