Reputation: 1233
In my project when I am trying to define the bean for AuthenticationManager
by overriding the AuthenticationManagerBean()
method it is showing the below error,
The method authenticationManagerBean() of type SecurityConfiguration must override or implement a supertype method
While the method I am defining is given below,
@Bean(name = BeanIds.AUTHENTICATION_MANAGER)
@Override
public AuthenticationManager authenticationManagerBean() throws Exception {
return super.authenticationManagerBean();
}
My entire SecurityConfiguaration
class is given below,
package com.toorjaridwan.introvertreadersauth.Configuration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.config.BeanIds;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.crypto.password.NoOpPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import com.toorjaridwan.introvertreadersauth.Service.UserDetailService;
@Configuration
@EnableWebSecurity
public class SecurityConfiguration {
@Autowired
private UserDetailService userDetailService;
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(userDetailService);
}
protected void configure(HttpSecurity http) throws Exception {
http.csrf().disable().authorizeRequests().antMatchers("/authenticate").permitAll()
.anyRequest().authenticated();
}
@Bean(name = BeanIds.AUTHENTICATION_MANAGER)
@Override
public AuthenticationManager authenticationManagerBean() throws Exception {
return super.authenticationManagerBean();
}
@Bean
public PasswordEncoder passwordEncoder() {
return NoOpPasswordEncoder.getInstance();
}
}
In a previous project which used Spring Boot version 2.1.9, everything went smoothly, no issue at all. Now I am using Spring Boot version 2.2.6. I do not know if it is the reason.
When searching for solution I came across this and this. I found things to be as similar as I did.
I am running a 64 bit Ubuntu 16.04 LTS and Java version 1.8
Upvotes: 1
Views: 5455
Reputation: 5852
try adding
extends WebSecurityConfigurerAdapter
to your configuration class
Upvotes: 3