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

解决java.lang.IllegalArgumentException: There is no PasswordEncoder mapped for the id "null" 使用springboot,权限管理使用spring security,使用内存用户验证,但无响应报错:java.lang.IllegalArgumentException: There is no PasswordEncoder mapped for the id "null"解决方法:这是因为Spring boot 2.0.3引用的security 依赖是 spring security 5.X... 阅读详情
问题描述:

使用springboot,权限管理使用spring security,使用内存用户验证,但无响应报错:
java.lang.IllegalArgumentException: There is no PasswordEncoder mapped for the id “null”

在Spring Security 5.0之前,默认值PasswordEncoder是NoOpPasswordEncoder需要纯文本密码。在Spring Security 5中,默认值为DelegatingPasswordEncoder,这需要密码存储格式。

解决方法:
方法一:- 添加密码存储格式,对于纯文本,添加{noop}

修改配置类代码,在密码前面加{noop}

    @Override
    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
//        super.configure(auth);
        auth.inMemoryAuthentication()
                .withUser("张三").password("{noop}123").roles("vip1","vip2")
                .and()
                .withUser("李四").password("{noop}123").roles("vip1");
    }
方法二:创建MyPasswordEncoder类实现PasswordEncoder,加注解 @Component
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Component;

@Component
public class MyPasswordEncoder implements PasswordEncoder {
    @Override
    public String encode(CharSequence charSequence) {
        return charSequence.toString();
    }

    @Override
    public boolean matches(CharSequence charSequence, String s) {
        return s.equals(charSequence.toString());
    }
}

配置类写法:加个.passwordEncoder(new MyPasswordEncoder())

    @Override
    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
//        super.configure(auth);
        auth.inMemoryAuthentication().passwordEncoder(new MyPasswordEncoder())
                .withUser("张三").password("123").roles("vip1","vip2")
                .and()
                .withUser("李四").password("123").roles("vip1");
    }
SpringSecurity报错:IllegalArgumentException: There is no PasswordEncoder mapped for the id “null“ springboot整合springSecurity通过配置类自定义用户名和密码的时候,提示报错信息:java.lang.IllegalArgumentException: There is no PasswordEncoder mapped for the id "null" 阅读详情

相关推荐

SDIO_WiFi驱动学习之SDIO架构介绍及源码分析

一、引言 因为WiFi驱动比较复杂,所以WiFi驱动的博客将分为两篇来写。 本篇博客主要介绍Linux下的SDIO架构及源码分析。 二、SDIO WiFi SDIO-Wifi模块是基于SDIO接口的符合wifi无线网络标准的嵌入式模块,内置无线网络协议IEEE802.11协议栈以及TCP/IP协议栈,能够实现用户主平台数据通过SDIO口到无线网络之间的转换。SDIO具有传输数据快,兼容SD、MMC接口等特点。 对于SDIO接口的WiFi,首先,它是一个SDIO的卡设备,然后具备了WiFi的功能。所

陈子陌的博客 1万+

解决java.lang.IllegalArgumentException: There is no PasswordEncoder mapped f...

解决java.lang.IllegalArgumentException: There is no PasswordEncoder mapped for the id 使用springboot,权限管理使用spring security,使用内存用户验证,但无响应报错: java.lang.IllegalArgumentException: There is no PasswordEncoder mapped for the id "null" 解决方法: 这是因为Spring boot 2.0.3

HongYu012的博客 2935

小白学习微信小程序的图像识别和文字识别技术

其中,type参数指定了识别的类型,imageUrl参数指定了图片的地址,success回调函数用于处理识别成功的结果,fail回调函数用于处理识别失败的情况。其中,type参数指定了识别的类型,imageUrl参数指定了图片的地址,success回调函数用于处理识别成功的结果,fail回调函数用于处理识别失败的情况。下面,我们来实现一个文字识别的应用案例,可以识别一张图片中的文字,并将识别结果显示到小程序的页面上。在小程序中,也可以使用微信提供的文字识别接口,实现文字识别的功能开发。

qq_67153941的博客 1643

There is no PasswordEncoder mapped for the id "null" 的解决办法

环境/问题概述: 在项目构建的过程中,根据需求进行了系统升级,包括硬件和软件环境,项目开发使用的 Spring Boot 进行的,这次升级直接从1.5.2 直接升级为了2.0.3; 在包更正完成后,启动项目测试,遇到不能登录系统的问题,异常信息如下: java.lang.IllegalArgumentException: There is no PasswordEncoder...

Spring Boot-Common On With You 2万+

YOLOv12超参数智能优化:基于内置Ray Tune的自动化调优实战指南

购买即可解锁300+YOLO优化文章,并且还有海量深度学习复现项目,价格仅需两杯奶茶的钱,别人有的本专栏也有! 目标检测模型的性能瓶颈往往源于超参数配置不当。传统手动调优方式不仅耗时耗力,且难以找到全局最优解。YOLOv12集成的Ray Tune框架为解决这一难题提供了完整方案,通过分布式异步优化算法,可实现超参数搜索效率的指数级提升。实际测试表明,采用Ray Tune自动调优的YOLOv12模型,在COCO数据集上mAP指标平均提升3.8%,收敛速度加快2.1倍。在VisDrone无人机数据集上的跨域测试

LXY_LOVE36的博客 119

Stable Diffusion 模型分享:Beautiful Realistic Asians(美丽真实的亚洲人)

Beautiful Realistic Asians(BRA)模型是由作者自己训练而成的一个独立模型,它是一个真实模型,并且是一个针对亚洲人训练的模型,可以生成非常漂亮的亚洲小姐姐。条目内容类型大模型基础模型SD 1.5来源CIVITAI作者文件名称文件大小1.99GB。

水滴的博客 2157

spring:Spring Security实践过程中的报错总结

要解决这个问题,你可以使用 io.jsonwebtoken.security.Keys 类中的 secretKeyFor 方法来生成一个安全的密钥。真实原因是SecurityContextHolder.getContext().getAuthentication().getPrincipal()结果是anonymousUser,anonymousUser 是 Spring Security 默认使用的一个特殊标识,表示未认证的用户。我在客户端调用自定义的路由 /login,提示302,服务端报错。

分享前端开发工程师的一些日常生活、前端知识点、职业发展、对一些问题的看法、感悟等等 1685

【YOLO】YOLOV5-Seg的Segment模块解析

Segment模块同时输出检测结果和分割掩模,通过轻量级分割头实现实时实例分割

浩瀚之水的专栏 599

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

今天刚学习springboot+spring security,结果访问请求登录时控制台报错: java.lang.IllegalArgumentException: There is no PasswordEncoder mapped for the id "null" at org.springframework.security.crypto.password.DelegatingP...

路西法Lucifer 4146

商品标签识别系统:基于YOLO系列的深度学习实现

随着零售行业的快速发展和自动化需求的增长,商品标签识别技术变得越来越重要。本文详细介绍了一个完整的商品标签识别系统,该系统基于YOLO系列目标检测算法(包括YOLOv5、YOLOv8和YOLOv10),采用PySide6构建用户界面,并提供完整的训练代码和数据集处理方案。该系统能够准确识别商品标签中的关键信息,如价格、条形码、生产日期等,为零售自动化、库存管理和智能结算提供技术支持。

YOLO 349

Playwright MCP:开启浏览器自动化的新篇章

在当今数字化时代,浏览器自动化技术在众多领域发挥着至关重要的作用,从简单的网页爬取到复杂的自动化测试,再到智能代理与网页的交互等场景,都离不开高效、可靠的浏览器自动化工具。而微软推出的项目,正是在这一领域的一次创新性探索,它为开发者带来了全新的视角和强大的功能支持。本文将深入探讨的概念、架构、代码示例、应用场景、注意事项以及未来发展方向,帮助读者全面了解这一前沿技术。

加入“Super Entity”,与全能开发团队共探AI智能体与数字人项目,开启前沿技术之旅。 5266

解决java.lang.IllegalArgumentException: There is no PasswordEncoder mapped for the id "null"

使用springboot,权限管理使用spring security,使用内存用户验证,但无响应报错: java.lang.IllegalArgumentException: There is no PasswordEncoder mapped for the id “null” 解决方法: 这是因为Spring boot 2.0.3引用的security 依赖是 spring security ...

570

学Simulink——基于软开关与高频变换的整流器系统场景实例:移相全桥ZVS整流器在轻载条件下的效率优化

本文以Simulink为平台,详细介绍了移相全桥ZVS整流器在轻载条件下的建模与优化方法。通过六个步骤系统讲解了从项目创建到仿真运行的全过程,重点分析了移相全桥拓扑结构、ZVS检测逻辑设计及轻载特性。结果显示,传统移相全桥在轻载时ZVS失效导致效率下降(<88%)。针对此问题,提出了动态频率调整、不对称半桥模式等优化策略。该案例为理解软开关技术、提升电源效率提供了实用建模方法和优化思路。

xiaoheshang_123的博客 117

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 */ @A...

图图是只猫 1473

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

android 蓝牙通讯demo

android 下蓝牙通讯demo,实现了发现蓝牙,使能蓝牙,通过蓝牙发送消息。

解决 java.lang.IllegalArgumentException: There is no PasswordEncoder mapped for the id "null"

pringboot,权限管理使用spring security,使用内存用户验证,但无响应报错: java.lang.IllegalArgumentException: There is no PasswordEncoder mapped for the id "null" 解决方法: 这是因为Spring boot 2.0.3引用的security 依赖是 spring security 5.X...

weixin_45863786的博客 373

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

报错:java.lang.IllegalArgumentException: There is no PasswordEncoder mapped for the id “null“解决的方式

目录一、报错描述二、报错原因三、解决方式 一、报错描述 springboot项目整个spring security权限管理,表单验证输入用户名和密码页面无响应,控制台报错如下图: 二、报错原因 lz自定了一个处理用户校验逻辑MyUserDeitailsService类,实现了UserDetailsService接口,但是在SecurityConfig配置类中没有注入PasswordEncoder实例,导致报错。 MyUserDeitailsService类代码如下: @Component pu

小志的博客 1621

锂电池充电器电路设计 里面有电路

锂电池充电器电路设计 里面有电路 3.7V升压到5V电路设计。

java.lang.IllegalArgumentException: There is no PasswordEncoder mapped for the id “null“ 产生原因

在做接口拦截器的时候自定义了一个配置类,但是运行在控制台上产生了java.lang.IllegalArgumentException: There is no PasswordEncoder mapped for the id "null" 的问题。这个问题主要是依赖SpringBoot2.x整合Security5所引发的问题。现在idea中找到了DelegatingPasswordEncoder类,在这个类中包含了一个私有类UnmappedIdPasswordEncoder,是由于mathes方法导致的这

hammring的博客 820

java.lang.IllegalArgumentException: There is no PasswordEncoder mapped for the id "null"报错

出现问题的原因:   内存用户验证时,Spring boot 2.0.1引用的security 依赖是 spring security 5.X版本,此版本需要提供一个PasswordEncorder的实例,否则后台汇报错误: java.lang.IllegalArgumentException: There is no PasswordEncoder mapped for the id "...

BigData 539

java.lang.IllegalArgumentException: There is no PasswordEncoder mapped for the id "null" (security)

  5.0以后的版本,有多种的加密方式,没有指定加密方式的方法。 两种解决方式修改成:   代码: import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframewor...

然而老干妈早就看穿了一切 747
上一篇: RedisTemplate序列化机制存储的自定义更改
下一篇: maven打包跳过打包test文件
Sonk.
博客等级 码龄8年 85粉丝 83原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Sonk.

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值