There is no PasswordEncoder mapped for the id “null” [How to Solve]

In the development of Java Web project, security authorization authentication mechanism is added

auth.inMemoryAuthentication().withUser("a").password("123456").roles("admin");

After the login page is submitted, the background display is abnormal

java.lang.IllegalArgumentException: There is no PasswordEncoder mapped for the id “null”

The main idea is that there is no password mapping added for ID. the code is adjusted according to the exception, and the passwordencoder method is added, as follows

auth.inMemoryAuthentication().passwordEncoder(new
         BCryptPasswordEncoder()).withUser("a").password(new BCryptPasswordEncoder().encode("123456")).roles("admin");

Run the program again and submit the account and password on the login page without exception

Similar Posts: