I am new to Spring Boot and trying to implement whatever I’ve learned from this link: login-registration-feature. My aim is to build a user login and registration feature but i’m stuck with this error:
*************************** APPLICATION FAILED TO START *************************** Description: Field authenticationManager in com.x.assignment.auth.service.SecurityServiceImpl required a bean of type 'org.springframework.security.authentication.AuthenticationManager' that could not be found. The injection point has the following annotations: - @org.springframework.beans.factory.annotation.Autowired(required=true) Action: Consider defining a bean of type 'org.springframework.security.authentication.AuthenticationManager' in your configuration.
My folder structure, code is same as the one mentioned in the link. But couldn’t figure out why @AutoWired is not working. Please help me. Thank you.
Advertisement
Answer
In the configuration class WebSecurityConfig
add bean directly:
@Bean @Override public AuthenticationManager authenticationManagerBean() throws Exception { return super.authenticationManagerBean(); }