티스토리 뷰

* Spring bean 생성 시, 예외 발생 에러 해결 방법



아아....... 오늘도 붉은 색 에러 창을 마주하게 되네요 하하:-(

어쩔 수 없는 초급 개발자의 운명이랄까요ㅋㅋㅋ...


일단 스크린 샷부터 볼까요?

눈여겨 볼 곳은 파란색 부분과 제가 녹색으로 칠해놓은 부분 인데요

어떤 에러인지 어떻게 해결 할 수 있는지 알아봅시다




스크린 샷의 원문을 텍스트로 옮겨 봤습니다

영문을 번역해보니...


105, 2016 10:04:47 오후 org.apache.catalina.core.ApplicationContext log

심각: StandardWrapper.Throwable

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'proTimetableController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.myspring.gachon.timetable.service.ProTimetableService com.myspring.gachon.timetable.controller.ProTimetableController.ProTimetableServiceImpl; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'proTimetableServiceImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.myspring.gachon.timetable.dao.ProTimetableDao com.myspring.gachon.timetable.service.ProTimetableServiceImpl.ProTimetableDao; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.myspring.gachon.timetable.dao.ProTimetableDao] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} 




Problem

Bean 생성 시 예외가 발생하여 생긴 에러 (파란색으로 색칠된 원문 참고)


현재 가천라인 프로젝트에서는 com.myspring.gachon.timetable.dao.ProTimetableDao를 사용하는데, 

이 bean 객체를 찾지 못해서 발생한 에러 (녹색 진하게 색칠된 원문 참고)




Solution

나의 경우 ProTimetableDaoImpl.java를 확인 해 보니 @repository annotation 이 빠져있었다  



깔끔하게 annotation 하나만 추가 해 주어 정상적으로 Dao bean 객체를 autowired 할 수 있게 되었다




Comment

솔직히 C V만 잘해도... 이런 실수는 안할 수 있을 텐데, 이런 annotation 에러는 정말 하지말자!

댓글