ੈ✩‧₊˚Computer Science/프론트엔드 | 백엔드

Bean creation exception 발생 원인/appservlet 을(를) 위한 servlet.init() 호출이 예외를 발생시켰습니다

샨샨 2020. 11. 27. 16:34
반응형

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'boardController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.my.myapp.BoardService com.my.myapp.BoardController.boardService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'boardServiceImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.my.dao.BoardDAO com.my.myapp.BoardServiceImpl.boardDAO; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.my.dao.BoardDAO] 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)} org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:287) org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1106)

 

이런 에러가 계속났다.

원래 bean exception에러는 어노테이션 에러인데, 분명히 어노테이션도 잘 썼는데 자꾸 이런 에러가 발생되었다.

 

어노테이션도 정확히 썼는데 자꾸 appservlet이라는 에러가 뜬다면 작성한 소스의 패키지를 잘 확인해봐야한다.

 

servlet-context.xml을 확인하면 <beans>태그 아래에

라는 것이 있는데, 내가 만든 controller,dao,vo 파일이 com.my.myapp이라는 패키지 안에 없었기 때문에 beancreationexception에러가 뜬 것이다.

 

해결방법) 모든 파일은 com.my.myapp 패키지 아래에 넣어주었더니 해결되었다.

 

반응형