There is no PasswordEncoder mapped for the id "null"
时间: 2024-02-14 07:18:40 浏览: 36
这个问题通常是由于未正确配置Spring Security所引起的。在Spring Security的配置中,需要指定一个PasswordEncoder,用于对密码进行加密和解密。但是,如果没有正确地配置PasswordEncoder,就会出现该错误。您可以检查您的配置文件,确保已经为所有需要加密的密码设置了PasswordEncoder并正确地映射了其id。同时,也要确保您的密码存储在安全的地方,并且不会被泄露。
相关问题
java.lang.IllegalArgumentException: There is no PasswordEncoder mapped for the id "null"
这个错误通常出现在 Spring Security 的配置中。它表示密码编码器的 ID 为 null,无法映射到任何密码编码器实现。
要解决这个问题,你需要在 Spring Security 配置中定义一个密码编码器,并将其 ID 映射到相应的实现类。
例如,如果你使用的是 BCryptPasswordEncoder,可以在配置中添加以下代码:
```
@Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
```
然后,将密码编码器的 ID 映射到实现类:
```
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth
.inMemoryAuthentication()
.withUser("user")
.password("$2a$10$3tFQ3tV9IqJ6jXzKbl3gjOZ4swbKjzP0C1Zd2Lz0uTbOsnXzLdLkO") // password is "password"
.roles("USER")
.and()
.passwordEncoder(passwordEncoder()); // map encoder id to implementation
}
```
这样应该就能解决这个问题了。
there is no action mapped for action name
"b'there is no action mapped for action name'" 的意思是“未为操作名称映射任何动作”,通常出现在 Web 应用程序的错误信息中,表示请求的操作名称无法找到对应的动作映射。这通常是由于操作名称输入错误、配置错误或未在配置文件中正确映射动作名称造成的。