Spring Security 报There is no PasswordEncoder mapped for the id "null"
查了下发现是spring security 版本在5.0后就要加个PasswordEncoder了
解决办法
- 在securityConfig类下加入NoOpPasswordEncoder,不过官方已经不推荐了
@Bean
public static NoOpPasswordEncoder passwordEncoder() {
return (NoOpPasswordEncoder) NoOpPasswordEncoder.getInstance();
}
- 在securityConfig类下加入密码加密,在数据库中存的密码也是要经过这个加密的才能匹配上
@Autowired
private UserDetailsService customUserService;
@Override
public void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(customUserService).passwordEncoder(new BCryptPasswordEncoder());
}
补充:加密操作
public static void main(String[] args) {
BCryptPasswordEncoder bCryptPasswordEncoder = new BCryptPasswordEncoder();
//加密"0"
String encode = bCryptPasswordEncoder.encode("0");
System.out.println(encode);
//结果:$2a$10$/eEV4X7hXPzYGzOLXfCizu6h7iRisp7I116wPA3P9uRcHAKJyY4TK
}
作者:yyq唯心不易
链接:https://www.jianshu.com/p/9e7792d767b2
来源:简书
简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。
Spring Security 报There is no PasswordEncoder mapped for the id "null"的更多相关文章
- spring security 5 There is no PasswordEncoder mapped for the id "null" 错误
转载请注明出处 http://www.cnblogs.com/majianming/p/7923604.html 最近在学习spring security,但是在设置客户端密码时,一直出现了一下错误提 ...
- Spring Security 无法登陆,报错:There is no PasswordEncoder mapped for the id “null”
编写好继承了WebSecurityConfigurerAdapter类的WebSecurityConfig类后,我们需要在configure(AuthenticationManagerBuilder ...
- java.lang.IllegalArgumentException: There is no PasswordEncoder mapped for the id "null"报错
出现问题的原因: 内存用户验证时,Spring boot 2.0.1引用的security 依赖是 spring security 5.X版本,此版本需要提供一个PasswordEncorder的实例 ...
- 005-SpringBoot2.x整合Security5(解决 There is no PasswordEncoder mapped for the id "null")
问题描述 SpringBoot升级到了2.0之后的版本,Security也由原来的版本4升级到了5 使用WebSecurityConfigurerAdapter继承重置方法 protected voi ...
- There is no PasswordEncoder mapped for the id "null"的解决办法
今日在SpringBoot项目中使用 Spring Security ,登录时发现报500错,报错信息如下: There is no PasswordEncoder mapped for the id ...
- java.lang.IllegalArgumentException: There is no PasswordEncoder mapped for the id "null"
问题描述 今天在使用SpringBoot整合spring security,使用内存用户验证,但无响应报错:java.lang.IllegalArgumentException: There is n ...
- There is no PasswordEncoder mapped for the id "null"
There is no PasswordEncoder mapped for the id "null" 学习了:https://blog.csdn.net/dream_an/ar ...
- SpringBoot整合升级Spring Security 报错 【The request was rejected because the URL was not normalized】
前言 最近LZ给项目框架升级, 从Spring1.x升级到Spring2.x, 在这里就不多赘述两个版本之间的区别以及升级的原因. 关于升级过程中踩的坑,在其他博文中会做比较详细的记录,以便给读者参考 ...
- oauth2(spring security)报错method_not_allowed(Request method 'GET' not supported)解决方法
报错信息 <MethodNotAllowed> <error>method_not_allowed</error> <error_description> ...
随机推荐
- HNUST-1148 ACM ranking rules(简单模拟)
1148: ACM ranking rules 时间限制: 1 Sec 内存限制: 128 MB提交: 16 解决: 12[提交][状态][讨论版] 题目描述 ACM contests, like ...
- P1399 [NOI2013]快餐店
传送门 基环树的题当然先考虑树上怎么搞,直接求个直径就完事了 现在多了个环,先把非环上的直径(设为 $ans$)和环上节点 $x$ 到叶子的最大距离(设为 $dis[x]$)求出来 考虑到对于某种最优 ...
- 使用T4模板为EF框架添加数据库实体注释(转)
1. 下载文件GetSummery.ttinclude2. 把我们下载下来的文件解压,将解压出来的文件放入解决方案中3. 修改下app.config,添加一个连接字符串: <add name=& ...
- css 超出部分显示省略号 汇总
单行: 加宽度 overflow: hidden; text-overflow:ellipsis; white-space: nowrap; 多行: display: -webkit-box; -we ...
- hadoop面试复习笔记(1)
0.Mappereduce采用的是Master/Slaves模型 1.Hadoop是一个开源软件框架,支持支持大数据集的存储和处理.Apache Hadoop是存储和处理大数据的解决方案你是因为: ( ...
- vue报错——Module not found: Error: Can't resolve 'less-loader sass' in ...
npm install sass-loader -D npm install node-sass -D
- 解析html,提取元素参数
r = s.get(loginurl, verify=False) dom = etree.HTML(r.content.decode("utf-8")) try: result[ ...
- ms17_0199样本测试
一大早就各种消息弹框,于是就来测试一波 https://github.com/nixawk/metasploit-framework/blob/8ab0b448fdce15999f155dfd7b22 ...
- Linux目录的切换
pwd:显示当前所在目录 ~:root目录 /:根目录 ls:查看当前目录下所有的文件和目录 cd usr 切换到该目录下usr目录 cd ../ 切换到上一层目录 cd / 切换到系统根目录 cd ...
- u-boot include目录 gd_t结构体 如何关联芯片指定的目录
1 u-boot /u-boot-2018.07-fmxx/include/config.h /* Automatically generated - do not edit */#define CO ...