解决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"

解决方式

①:

创建MyPasswordEncoder类实现PasswordEncoder,加注解  @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());
    }
}
    @Override
    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
        //如果程序报错There is no PasswordEncoder mapped for the id "null",就将该段注释添加下边代码
        //或者在MyPasswordEncoder类上加一个@Component注解,使它成为一个Bean
        auth.inMemoryAuthentication().withUser("admin").password("123456").authorities("ADMIN_ADD","ADMIN_FIND");//自定义登录用户用户名和密码并赋予一些权限
    }

②:

    @Override
    protected void configure(AuthenticationManagerBuilder auth) throws Exception {

        //这个是使用了匿名内部类
        auth.inMemoryAuthentication().passwordEncoder(new MyPasswordEncoder()).withUser("lxy").password("lxy").authorities("ADMIN_ADD","ADMIN_FIND");
    }

原文地址:https://www.cnblogs.com/think-world/p/12306217.html

时间: 2024-08-30 03:32:10

解决java.lang.IllegalArgumentException: There is no PasswordEncoder mapped for the id "null"的相关文章

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 "null" 并且页面毫无响应. 解决方法: 创建PasswordEncorder的实现类MyPassw

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

在spring security中设置默认的登录人的信息,遇到的异常信息: java.lang.IllegalArgumentException: There is no PasswordEncoder mapped for the id “null” 有些版本不要求这样子做,所以就不会有该问题的发生, 我现在用的是5.0版本,强制要求提供一个,所以我们就给一个PasswordEncoder给他. 我们也可以使用Spring自带的PasswordEncoder.为了方便起见,我们以明文形式存密码

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

今天在配置spring-security.xml配置文件时出错 错误如下: 严重: Servlet.service() for servlet [security] in context with path [] threw exception java.lang.IllegalArgumentException: There is no PasswordEncoder mapped for the id "null" at org.springframework.security.c

java.lang.IllegalArgumentException: XXX is ambiguous in Mapped Statements collection

问题的出现: 在后台添加一个新栏目的时候,照着程序已有原来的代码添加新的功能时,文件没有错误.点击新的栏目的时候报了java.lang.IllegalArgumentException: selectPageByExample is ambiguous in Mapped Statements collection (try using the full name including the namespace, or rename one of the entries). 解决: 在网上查找了

view.setTag(key,Object) (java.lang.IllegalArgumentException: The key must be an application-specific resource id.)

转自: http://blog.csdn.net/brokge/article/details/8536906 setTag是android的view类中很有用的一个方法,可以用它来给空间附加一些信息,在很多场合下都得到妙用. setTag(Object tag)方法比较简单,这里主要谈一谈带两个参数的setTag方法. 官方的api文档中提到:" The specified key should be an id declared in the resources of the applica

There is no PasswordEncoder mapped for the id "null"

因为Spring-Security从4+升级到5+,导致There is no PasswordEncoder mapped for the id “null”错误. 解决方案: 1.可在密码验证类中添加 @Bean public static NoOpPasswordEncoder passwordEncoder() { return (NoOpPasswordEncoder) NoOpPasswordEncoder.getInstance(); } 2.或者在xml配置文件中添加 <b:be

170616、解决 java.lang.IllegalArgumentException: No converter found for return value of type: class java.util.ArrayList

报错截图: 原因:搭建项目的时候,springmvc默认是没有对象转换成json的转换器的,需要手动添加jackson依赖. 解决步骤: 1.添加jackson依赖到pom.xml <!-- jaskson --> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-core</artifactId> <version>

解决Android studio 启动报错java.lang.RuntimeException: java.lang.IllegalArgumentException

报错内容 Internal error. Please report to https://code.google.com/p/android/issues java.lang.RuntimeException: java.lang.IllegalArgumentException: Argument for @NotNull parameter 'name' of com/android/tools/idea/welcome/Platform.<init> must not be null 

【已解决】java.lang.IllegalArgumentException: column &#39;_id&#39; does not exist

今天用到SimpleCursorAdapter来适配ListView的数据,依旧记得SimpleCursorAdapter必须匹配一个字段名为_id的主键列,一开始我用SQLiteDatabase的rawQuery方法拼sql查询,因为是用SELECT * FROM table_name,所以一切正常. 后来我用query方法就挂了,抛出了java.lang.IllegalArgumentException: column '_id' does not exist异常,然后我发现原来是参数col