spring boot

Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(classes=...) with your test

원코드 2022. 10. 25. 14:28

@SpringBootApplication 이 어노테이션은 스프링 부트의 자동 설정을 읽는 + bean을 생성하고 읽는 어노테이션이기 때문에 가장 상위 패키지에 존재해야 한다.

제목의 오류는 테스트하려는 클래스가 위의 어노테이션이 붙은 패키지의 하위에 있지 않아 읽을 수 없을 때 발생하는 오류인데, 내 프로젝트는 분명 저 어노테이션이 붙어있는 Application 클래스의 하위에 잘 넣어두었는데도 오류가 났다. 

실패했을 때의 구조

찾아보니 앞에 생략된 패키지들 때문에 구조가 다르게 되어서 그런거였다.

com.odog.www.web이 되야하는데 www.web만 존재해서 생긴 오류

https://stackoverflow.com/questions/47487609/unable-to-find-a-springbootconfiguration-you-need-to-use-contextconfiguration

 

Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(classes=...) with your test

I am using Spring Data JPA and Spring Boot. The layout of the application is this main +-- java +-- com/lapots/game/monolith +-- repository/relational +--

stackoverflow.com

성공했을 때 구조

앞에 생략된 패키지 추가했더니 성공함