异常描述:

java.lang.IllegalArgumentException: There is no PasswordEncoder mapped for the id “null”
at org.springframework.security.crypto.password.
DelegatingPasswordEncoder$UnmappedIdPasswordEncoder.matches(DelegatingPasswordEncoder.java:244)~[spring-security-core-5.1.5.RELEASE.jar:5.1.5.RELEASE]at org.springframework.security.
crypto.password.DelegatingPasswordEncoder.matches(DelegatingPasswordEncoder.java:198)
~[spring-security-core-5.1.5.RELEASE.jar:5.1.5.RELEASE]

我们在这个异常中,可以看到主要原因是: There is no PasswordEncoder mapped for the id “null”

即我们在对密码进行编码的时候没有指定对应的密码编码器.这个原因是由于在spring security5中,密码的存储需要进行编码,所以需要添加编码格式,spring Security框架已经为我们定制好了一些默认编码器,我们只需要在代码中声明即可

出错的代码

@Configuration
@EnableWebSecurity
public class SpringSecurityConfig extends WebSecurityConfigurerAdapter {@Overrideprotected void configure(AuthenticationManagerBuilder auth) throws Exception {//基于内存管理的角色授权登录系统auth.inMemoryAuthentication().withUser("admin").password("123456").roles("ADMIN"); }}

更改方法一,但由于不安全,官方不推荐  【指定了NoOpPasswordEncoder进行编码】

@Configuration
@EnableWebSecurity
public class SpringSecurityConfig extends WebSecurityConfigurerAdapter {@Overrideprotected void configure(AuthenticationManagerBuilder auth) throws Exception {//基于内存管理的角色授权登录系统auth.inMemoryAuthentication().withUser("admin").password("{noop}123456").roles("ADMIN"); }}

参考:

https://spring.io/blog/2017/11/01/spring-security-5-0-0-rc1-released#password-storage-format            https://www.mkyong.com/spring-boot/spring-security-there-is-no-passwordencoder-mapped-for-the-id-null/

springboot 2.x升级后出现Spring Security – There is no PasswordEncoder mapped for the id “null”的解决方案相关推荐

  1. 关于Spring Security中显示There is no PasswordEncoder mapped for the id “null“的问题分析

    关于Spring Security中显示There is no PasswordEncoder mapped for the id "null"的问题分析 1 Spring Sec ...

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

    编写好继承了WebSecurityConfigurerAdapter类的WebSecurityConfig类后,我们需要在configure(AuthenticationManagerBuilder ...

  3. Spring Security:密码编码器PasswordEncoder介绍与Debug分析

    博主在之前已经介绍了Spring Security的用户UserDetails与用户服务UserDetailsService,本篇博客介绍Spring Security的密码编码器PasswordEn ...

  4. springboot 访问html_Spring Boot中使用Spring Security进行安全控制

    我们在编写Web应用时,经常需要对页面做一些安全控制,比如:对于没有访问权限的用户需要转到登录表单页面.要实现访问控制的方法多种多样,可以通过Aop.拦截器实现,也可以通过框架实现(如:Apache ...

  5. Spring Boot + Mybatis——RowBoundsPlugin造成的[Mapped Statements collection already contains value]解决方案

    基本概念 RowBoundsPlugin:通过ResultSet的游标实现的分页查询插件,容易出现性能问题 <plugin type="org.mybatis.generator.pl ...

  6. Spring Boot+Vue/前后端分离/高并发/秒杀实战课程之spring Security快速搭建oauth2 内存版身份认证

    Springboot快速搭建oauth2 内存版身份认证 环境准备 点击[Create New Project]创建一个新的项目 项目环境配置 配置Thymeleaf 搭建oauth2认证,加入两个依 ...

  7. 31 | SpringBoot安全之整合Spring Security

    一.安全 应用程序的两个主要区域是"认证"和"授权"(或者访问控制),这两个主要区域是安全的两个目标. 身份验证意味着确认您自己的身份,而授权意味着授予对系统的 ...

  8. SpringBoot第二十三篇:安全性之Spring Security

    作者:追梦1819 原文:https://www.cnblogs.com/yanfei1819/p/11350255.html 版权声明:本文为博主原创文章,转载请附上博文链接! 引言   系统的安全 ...

  9. SpringBoot 集成 Spring Security

    Spring Security Spring Security是一个功能强大且高度可定制的身份验证和访问控制框架.它实际上是保护基于spring的应用程序的标准. Spring Security是一个 ...

最新文章

  1. swoole单台并发php,php swoole 并发多少?
  2. 南邮 AAencode
  3. 2020年快手短视频直播电商营销增长宝典
  4. SQLAlchemy Mapping Table Columns
  5. mysql连表删除语句_MySQL中联表更新与删除的语法介绍
  6. SQL语句详解(一)——基本增删改操作
  7. 【常见Web应用安全问题】---12、URL redirection
  8. 学习类App原型制作分享-Wokabulary
  9. 计算机硬盘驱动是什么,电脑重装系统时提示缺少硬盘驱动该怎么解决
  10. 常识:如何从大陆拨打国际长途电话到境外的方法
  11. php微信授权登录sdk,微信授权登录如何使用?总结微信授权登录实例用法
  12. CURL 发送请求详解
  13. 关于typora的天坑
  14. 针式个人知识管理系统帮助:实现您的PKM梦想!
  15. 计算机考研就业率,这8个考研专业,就业率一直居高不下,报了就是赚了!
  16. 目标检测算法——YOLOv5/YOLOv7改进之结合特征提取网络RFBNet(涨点明显)
  17. 微信点击链接直接下载安装包功能实现方式
  18. 看个小程序,测测你细心不细心
  19. 我是如何从屌丝程序员逆袭成为大厂总监的?
  20. 达人篇:6.3)试验设计DOE,Design of Experiments

热门文章

  1. 使用Android Studio来为Cocos2dx-lua项目打包
  2. 线性代数之向量间线性关系
  3. matlab恒定值,基于MATLAB的明渠恒定非均匀渐变流水面线的数值计算
  4. CLIP(Learning Transferable Visual Models From Natural Language Supervision)
  5. 创建 DBLink 的方法
  6. 如何将JPG图片转换成WEBP格式
  7. 云桌面系统功能参数(备忘)
  8. 关于腾讯云服务器使用FTP详细配置教程
  9. SAAS的概念及优缺点
  10. 在MySQL中创建Oracle中的dept、emp、bonus、salgrade表