Could not autowire field:private org.springframework.security.crypto.password.PasswordEncoder;

use this bean :

@Bean
PasswordEncoder getEncoder() {
    return new BCryptPasswordEncoder();
}

You must make your password encoder a bean:

@Bean
public PasswordEncoder passwordEncoder() {
    return new ShaPasswordEncoder();
}

Then you can autowire it.


you can use any of the following

@Bean
PasswordEncoder getEncoder() {
    return new BCryptPasswordEncoder();
}

OR

@Bean
public PasswordEncoder passwordEncoder() {
    return new ShaPasswordEncoder();
}