Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Springboot 3.0.0-M2 AuthenticationManager

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.

like image 265
Plugrol Huldo Avatar asked Sep 15 '25 22:09

Plugrol Huldo


1 Answers

In your configuration class you can add this:

@Bean
public AuthenticationManager authenticationManager(AuthenticationConfiguration authenticationConfiguration) 
         throws Exception {
    return authenticationConfiguration.getAuthenticationManager();
}
like image 138
Szakul1 Avatar answered Sep 18 '25 19:09

Szakul1