今天在用spring security时遇到了There is no PasswordEncoder mapped for the id “null”的错误,参考了Canon_in_D_Major的博文https://blog.csdn.net/canon_in_d_major/article/details/79675033,在此表示感谢!
但是这里有一个坑需要注意一下,就是
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
//inMemoryAuthentication 从内存中获取
auth.inMemoryAuthentication().passwordEncoder(new BCryptPasswordEncoder()).withUser(“user1”).password(new BCryptPasswordEncoder().encode(“123456”)).roles(“USER”);
}
方法需要修改为public的访问权限,否则会报404错误,修改后的方法如下:
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
//inMemoryAuthentication 从内存中获取
auth.inMemoryAuthentication().passwordEncoder(new BCryptPasswordEncoder()).withUser(“admin”).password(new BCryptPasswordEncoder().encode(“123456”)).roles(“ADMIN”);
}
继续阅读与本文标签相同的文章
数据结构之对引用数据类型数组CURD(二)
-
3D打印在玩具行业的应用
2026-05-18栏目: 教程
-
湖北移动誓师第七届世界军人运动会通信保障
2026-05-18栏目: 教程
-
环保新主义:企业无纸化办公
2026-05-18栏目: 教程
-
华能+华为=光伏技术标杆
2026-05-18栏目: 教程
-
淘集集经营模式变更:合伙人自营,主要供应商已成股东合伙人
2026-05-18栏目: 教程
