zoukankan      html  css  js  c++  java
  • There is no PasswordEncoder mapped for the id "null"

    springboot集成 spring-security认证报错-->  There is no PasswordEncoder mapped for the id "null"

    在网上看到说是 springboot 2.1.x之前可以直接使用,之后认证就会

    There is no PasswordEncoder mapped for the id "null"

    解决方案:

      

    //认证 springboot 2.1.x 可以直接使用~
        //密码编译,passwordEncoder
        //在spring security 5.0+ 新增了很多的加密方式~ 如果没有密码,会不让你使用,明文密码会遭受到反编译,不安全
        @Override
        protected void configure(AuthenticationManagerBuilder auth) throws Exception {
    
            //这些数据正常应该是从数据库中读取
            auth.inMemoryAuthentication().passwordEncoder(new BCryptPasswordEncoder())
                    .withUser("aaa")password(new BCryptPasswordEncoder().encode("123456")).roles("vip2","vip3")
              .and()
              .withUser(
    "root").password("123456").roles("vip1","vip2","vip3")
              .and()
              .withUser(
    "guest").password("123456").roles("vip1") ; }

      

  • 相关阅读:
    [树状数组]JZOJ 4658 小Z调顺序
    [差分数组]JZOJ 3187 的士
    [BFS]JZOJ 4671 World Tour
    [BFS]JZOJ 4672 Graph Coloring
    [数学]JZOJ 4673 LCS again
    shell:正则表达式和文本处理器
    开发脚本自动部署及监控
    Linux中的重启命令
    nginx和nfs
    网络相关配置
  • 原文地址:https://www.cnblogs.com/ljy9/p/14416702.html
Copyright © 2011-2022 走看看