I wanted to create a backend using spring boot. When I executed the application, this exception was thrown:
Field authenticationManager in projekt.controller.AuthController required a bean of type 'org.springframework.security.authentication.AuthenticationManager' that could not be found.
I quickly found a solution on the internet, which includes adding a WebSecurityConfigurerAdapter in which I would add this method:
@Override
@Bean
public AuthenticationManager authenticationManagerBean() throws Exception {
return super.authenticationManagerBean();
}
But as I had to see, this is deprecated.
My question is how would I do the same thing without using something deprecated.
In your configuration class you can add this:
@Bean
public AuthenticationManager authenticationManager(AuthenticationConfiguration authenticationConfiguration)
throws Exception {
return authenticationConfiguration.getAuthenticationManager();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With