Ошибку "There is no PasswordEncoder mapped for the id "null"" можно исправить, добавив конфигурацию для PasswordEncoder в класс SecurityConfig. В Spring Security 5.x, требуется использование PasswordEncoder для шифрования пароля.
Вместо удаления кодировки пароля, вам следует добавить конфигурацию PasswordEncoder в ваш класс SecurityConfig. Вот пример того, как это можно сделать:
```java
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
private UserDetailsService userDetailsService;
@Bean
public PasswordEncoder passwordEncoder() {
return PasswordEncoderFactories.createDelegatingPasswordEncoder();
}
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(userDetailsService).passwordEncoder(passwordEncoder());
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/public/**").permitAll()
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/login")
.loginProcessingUrl("/j_spring_security_check")
.defaultSuccessUrl("/home")
.failureUrl("/login?error=true")
.permitAll()
.and()
.logout()
.logoutUrl("/logout")
.logoutSuccessUrl("/login")
.permitAll();
}
}
```
В этом примере мы добавляем бин passwordEncoder(), который использует PasswordEncoderFactories для создания PasswordEncoder по умолчанию. Затем мы передаем passwordEncoder() в метод authenticationManager() в методе configure(AuthenticationManagerBuilder auth). Это гарантирует, что пароли будут кодироваться и проверяться при аутентификации.
После внесения этих изменений, ошибка "There is no PasswordEncoder mapped for the id "null"" должна быть исправлена.