IT TIPS/Spring
[Spring] NoSuchBeanDefinitionException 해결방법
염염(FLIP)
2017. 8. 8. 13:28
@Autowired 대상 객체가 메모리에 없을 때
컨테이너는 NoSuchBeanDefinitionException 을 발생시킨다
해당 객체가 메모리에 생성되어 있어야 하므로 다음 두가지 방법으로 해결하면 된다
1. XML 설정
<bean id="id" class="클래스경로"></bean>
2. Annotation 설정
해당 클래스 파일로 들어가 Annotation을 추가해준다
@Component("id")
public class TestClass {
...
}
이 때, id값의 오타로 인해서 Execption이 발생될 수도 있으니 오타 주의!