서비스 시작시 아래메시지가 발생하였다. 문제를 확인하고 해결해보자.
Error Message.
org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘OpdController‘: Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named ‘OpdService‘ available
작성일 : 2021-03-24
컨텍스트에 없는 빈을 주입하려 할때 발생한다.
OpdService에 @Service 어노테이션을 선언해주어야 한다.
1 2 3 4 5 6 7 8 | @Controller public class OpdController { @Autowired private OpdService opdService; ... } |
1 2 3 4 | @Service public class OpdServiceImpl implements OpdService { ... } |
다른 빈 ID를 사용하려 했을때 실수로 잘못된 이름에 주의한다.
1 2 3 4 5 6 7 8 9 | @Controller public class OpdController { @Autowired @Qualifier ( "renameService" ) private OpdService opdService; ... } |
1 2 | <!-- XML 선언 --> < bean id = "renameService" class = "com.opendocs.project.OpdServiceImpl" /> |
1 2 3 4 5 | // Annotation 선언 @Service ( "renameService" ) public class OpdServiceImpl implements OpdService { ... } |