Bean 관련 에러
Consider defining a bean of type of type ‘org.springframework.security.core.userdetails.UserDetailsService’ in your configuration.
‘org.springframework.security.core.userdetails.UserDetailsService’that could not be found.
이 문구가 나왔을 때 UserDetailsService를 확인했다. 클래스를 확인해보니 Interface 형태였고, UserDetailsService가 가져오려는 메소드들은 User 엔티티에 UserDetails로 implementaion해둔 상태였다.
나는 여기서 UserDetailsService는 JPARepository들 처럼 spring boot 내부적으로 구현 코드가 있을 것이라 생각했는데 그렇지 않았다. 직접 UserDetailsService를 implementation하여 관련 메소드를 구현하는 service가 필요하였다.
이처럼 bean을 생성할 수 없을 때(클래스가 구현되지 않았는데 생성자에서 주입하려할 때) 생기는 오류이다.
직후에 비슷하게 생긴 오류로는 구현하려고 미리 클래스만 만들어두고 구현해놓지 않은 클래스를 생성자 형태로 주입하려 할 때 동일한 오류가 발생하게 되었다.
'개발 인생 > 자바' 카테고리의 다른 글
[Spring] ApplicationContextAware (0) | 2022.03.15 |
---|---|
[Spring] IoC/DI 제어의 역전/의존성 주입 (0) | 2022.03.12 |
[스프링]Get과 관련된 Annotation (0) | 2022.03.08 |
[java] 람다식 (0) | 2022.02.07 |