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") ; }

      

  • 相关阅读:
    USACO 4.1 Fence Rails
    POJ 1742
    LA 2031
    uva 10564
    poj 3686
    LA 3350
    asp.net MVC 3多语言方案--再次写, 配源码
    使用Log4net记录日志
    在C#用HttpWebRequest中发送GET/HTTP/HTTPS请求
    为什么要使用反射机制
  • 原文地址:https://www.cnblogs.com/ljy9/p/14416702.html
Copyright © 2011-2022 走看看