Error-Exception in thread "main" org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'bbsService' available 해결방법

CODEDRAGON Development/Spring

반응형


 

오류메시지

Exception in thread "main" org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'bbsService' available

 


 

<context:component-scan> 태그 통해 스캔하는 경우 getBean() 인자를 변경하여 호출해 주어야 합니다.

 

 

 

 

 

해결방법

Spring 설정 XML 등록한 BeanID Bean 클래스 타입을 인자로 하는 getBean()함수를

Bean 클래스 타입만 인자로 받는 함수로 변경해서 Lookup 합니다.

HelloService bbsService = ctx.getBean("helloService", HelloService.class);

HelloService bbsService = ctx.getBean(HelloService.class);

 

 



반응형