我是靠谱客的博主 苹果云朵,这篇文章主要介绍java.lang.IllegalArgumentException: There is no PasswordEncoder mapped for the id “null”,现在分享给大家,希望可以做个参考。

Spring Boot2集成Security时候在页面输入用户名密码出现的异常,这是配置用户的代码

java.lang.IllegalArgumentException: There is no PasswordEncoder mapped
for the id “null”

/**
* 描述:配置内存用户
* @param auth
* @throws Exception
*/
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth
.inMemoryAuthentication()
.withUser("唐伯虎").password("123456").roles("ADMIN")
.and()
.withUser("秋香").password("123456").roles("USER");
}

解决:SpringBoot2集成Security的时候没有加版本号,所以集成的Security 5版本的,它在设置密码的时候需要增加如下代码

下面代码是不使用加密策略
如果使用加密策略可以配置Security的Bycrpt

@SuppressWarnings("deprecation")
@Bean
public static NoOpPasswordEncoder passwordEncoder() {
return (NoOpPasswordEncoder) NoOpPasswordEncoder.getInstance();
}

最后

以上就是苹果云朵最近收集整理的关于java.lang.IllegalArgumentException: There is no PasswordEncoder mapped for the id “null”的全部内容,更多相关java.lang.IllegalArgumentException:内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(56)

评论列表共有 0 条评论

立即
投稿
返回
顶部