- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
spring boot报错:There is no PasswordEncoder mapped for the id "null"
原因:新版spring boot需要在自定义的WebSecurityConfigurerAdapter里面的
configure(AuthenticationManagerBuilder auth)
函数里面为明文密码实现一个密码加密器。
解决方案:在自己继承的WebSecurityConfigurerAdapter的类中的
configure(AuthenticationManagerBuilder auth)
中,自定义一个密码加密器类,为明文加密。例如:
@Override
public void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication()
.withUser("admin")
.password("admin").roles("USER", "ADMIN")
.and()
.withUser("fly")
.password("123456").roles("USER")
.and()
.passwordEncoder(new MyPasswordEncoder());
}
其中的
MyPasswordEncoder
即为自定义的密码加密器。其实现为:
import org.springframework.security.crypto.password.PasswordEncoder;
public class MyPasswordEncoder implements PasswordEncoder {
@Override
public String encode(CharSequence rawPassword) {
return rawPassword.toString();
}
@Override
public boolean matches(CharSequence rawPassword, String encodedPassword) {
return rawPassword.equals(encodedPassword);
}
}
目前我得到了主课: package com.recweb.springboot; import org.springframework.boot.SpringApplication; import o
我的密码编码器有问题, 我的代码: @Service public class UserService { private static final String DEFAULT_ROLE =
我正在使用 Spring-Boot v1.3.0.M2。我正在尝试使用注释定义一个 o.s.s.c.p.PasswordEncoder 。我的配置类如下所示。这个例子运行良好。 @Configurat
实现 Bcrypt 密码编码器后,我无法进行身份验证(凭据无效)。这是我要添加的用户: userRepository.save(new User("First", "Last", "user", "u
spring boot报错:There is no PasswordEncoder mapped for the id "null" 原因:新版spring boot需要在自定义的WebSecurit
我目前正在我的大学从事 Spring Boot/Angular 项目。我正在为 BCryptPasswordEncoder 的匹配函数苦苦挣扎,它总是返回 false。 用户.java @Entity
我正在尝试学习 spring 并创建一个网站,其中身份验证将通过登录页面关闭,角度传递给 spring,需要使用 ldap 进行身份验证。我想我会从 Spring 站点开始并浏览那里的指南,但它似乎使
我成功地建立了内存认证。但是当我要使用数据库构建它时,会出现这个错误。 There is no PasswordEncoder mapped for the id "null" 这是后续教程 - Sp
我正在使用 Spring 4.0.8 RELEASE 和 Spring-Security 3.2.5 RELEASE 我正在使用只有注册用户才能访问的 HTTP 摘要构建 REST Web 服务。 我
从 Spring Security 3.1.4.RELEASE 开始,旧的 org.springframework.security.authentication.encoding.PasswordE
我已经在我的 struts2 应用程序上实现了 Spring security,它运行良好,但它在第 3 行遇到错误 java.lang.NullPointerException。 虽然看起来 pas
我已经在我的 struts2 应用程序上实现了 Spring security,它运行良好,但它在第 3 行遇到错误 java.lang.NullPointerException。 虽然看起来 pas
在我的网络应用程序上部署时出现此错误 Context initialization failed org.springframework.beans.factory.BeanCreat
我正在从 Spring Boot 1.4.9 迁移到 Spring Boot 2.0 以及 Spring Security 5,并且我尝试通过 OAuth 2 进行身份验证。但我收到此错误: java
我已经存储(并编码)了一个电子邮件密码。我使用过 PasswordEncoder(Spring 安全)。 passwordEncoder.encode(password); 现在我需要对其进行解码以便
我可以使用一些建议来模拟 Grails 单元测试中使用的自动连接依赖项。我已经省略了大部分不必要的代码,只给出了测试类和被测文件类中的相关方法 class UserService { def
我正在从 Spring Boot 1.4.9 迁移到 Spring Boot 2.0 以及 Spring Security 5,我正在尝试通过 OAuth 2 进行身份验证。但是我收到了这个错误: j
我正在尝试运行一个基本的安全应用程序,当我在 Postman 中输入凭据时,我没有收到预期的 token 。我正在学习基本教程并正确执行了所有步骤,但我得到 401“未授权”状态。我试过使用 Bcry
使用 Spring Security Oauth2 时,我正在尝试对存储在数据库中的客户端 secret 进行 BCrypt 加密。我可以看到 JdbcClientDetailsService有一个
升级IDEA后启动项目时出现问题。 当前错误如下: CONFIGURE SUCCESSFUL in 2s |Running application... > Task :compileJava NO-
我是一名优秀的程序员,十分优秀!