java.lang.IllegalArgumentException: There is no PasswordEncoder mapped for the id "null"
Or null can be any unknown password encoding algorithm.To fix this error, you need to specify a password encoder explicitly this way:public class WebSecurityConfig extends WebSecurityConfigurerAdapter { @Bean public PasswordEncoder passwordEncoder() { return new BCryptPasswordEncoder(); } @Override protected void configure(AuthenticationManagerBuilder auth) throws Exception { ... } @Override protected void configure(HttpSecurity http) throws Exception { ... } }Or, in case you’re using in-memory authentication, specify the password encoder like this:
@Override protected void configure(AuthenticationManagerBuilder auth) throws Exception { auth.inMemoryAuthentication() .passwordEncoder(new BCryptPasswordEncoder()) .withUser("namhm").password("$2a$10$fUXt47JTx/Rv/OHBkQgqAOvan445zDU7tCZcHr...") .roles("USER") ; }If you are using JDBC, fix the error “there is no PasswordEncoder mapped” as follows:
@Autowired public void configAuthentication(AuthenticationManagerBuilder auth) throws Exception { auth.jdbcAuthentication().passwordEncoder(new BCryptPasswordEncoder()); }You may also get the same error if you specify wrong prefix for in-memory password accidentally like this:
@Override protected void configure(AuthenticationManagerBuilder auth) throws Exception { auth.inMemoryAuthentication() .withUser("namhm").password("{bvrypt}$2a$10$fUXt47JTx/Rv/OHBkQgqAOvan445zDU7tCZcHr...") .roles("USER") ; }Spring will report this error:
java.lang.IllegalArgumentException: There is no PasswordEncoder mapped for the id "bvrypt"