[DEV] 기록

[SpringBoot 2.X.X] No beans of 'AuthenticationManager' type found.

꾸준함. 2022. 10. 20. 00:46

개요

Spring Security를 적용하는데 아래와 같은 메시지와 함께 에러가 발생했습니다.

 

Could not autowire. No beans of 'AuthenticationManager' type found.

 

원인

release note에 따르면 1점대 버전에서는 별도 처리 없이 SpringBoot에서 제공하는 AuthenticationManager를 주입시킬 수 있었지만 2점대 버전부터는 WebSecurityConfigurerAdapter를 상속받는 클래스에서 authenticationmanagerBean() 메서드를 오버라이드 해야 autowire가 가능했습니다.

자세한 내용은 아래 링크로 첨부합니다.

https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.0-Migration-Guide#authenticationmanager-bean

 

GitHub - spring-projects/spring-boot: Spring Boot

Spring Boot. Contribute to spring-projects/spring-boot development by creating an account on GitHub.

github.com

 

해결방법

아래 코드와 같이 WebSecurityConfigurerAdapter를 상속 받는 WebMvcConfig 클래스에 authenticationManagerBean() 메서드를 오버라이드 해주면 됩니다.


 

참고

https://stackoverflow.com/questions/49348551/could-not-autowire-authentication-manager-in-spring-boot-2-0-0

 

Could not autowire authentication manager in Spring Boot 2.0.0

So I've been trying to implement oAuth2 in a simple Spring MVC app. In the guide I was following, in their AuthorizationServerConfigurerAdapter they @Autowired an AuthenticationManager. They used ...

stackoverflow.com

 

반응형