개발일지 (5)번의 에러를 해결한 후 본격적으로 api 개발을 시작했다.
다른 팀원이 먼저 개발을 시작했는데, 오류 해결이 안돼 같이 해결 방법을 찾기 시작했다.
구글링을 3시간 넘게 했다. 팀원은 나보다 두시간 더 함..
Field UserRepository in (경로).UserService required a bean of type '(경로).UserRepository' that could not be found.
The injection point has the following annotations:
-@org.springframework.beans.factor.annotation.Autowired(required=true)
Action :
consider defining a bean of type '(경로).UserRepository' in your configuration.
project에서 특정 bean을 찾지 못해 발생하는 에러라고 한다.
이 에러에 대해 다룬 거의 모든 사람들이
main 클래스에
@ComponentScan(basePackages={"찾지 못하는 패키지 루트"})
또는
@SpringBootApplication(scanBasePackages={"찾지 못하는 패키지 루트"})
를 추가
@Service annotation 추가
이 두가지 방법으로 오류를 해결했다고 하여 둘 다 시도해 보았으나 해결되지 않았다.
그리고 계속해서 구글링을 한 결과 다음 페이지를 찾을 수 있었다.
https://www.javafixing.com/2022/01/fixed-java-spring-boot-consider.html
이 분은 해결하는데 17일이 걸렸다고 한다...
결국 원인은 개발일지 (5)번에서 추가한 다음 문장이었다.
spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
application.properties에서 이 문장을 지웠더니 바로 해결되었다.
이 오류가 발생했을 때 다른 분들은 우리처럼 헤매지 않길 바란다.
[참고]
https://www.javafixing.com/2022/01/fixed-java-spring-boot-consider.html
백엔드 대장님 왤케 열심히해요