Total Pageviews

2011/08/18

org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [gov.fdc.nig.controlop.NIG225Manager] found for dependency

Problem
As I execute my function, it show this error message
 Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [gov.fdc.nig.controlop.NIG225Manager] 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)}   
 at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:920)   
 at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:789)   
 at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:703)   
 at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:478)   
 ... 42 more   


Controller class is as bellowing
 /**   
 *   
 */   
 package gov.fdc.nig.web.controlop.controller;   
 /**   
 * @author albert   
 *   
 */   
 @Controller   
 @RequestMapping("/front/NIG225W")   
 public class NIG225Controller extends AbstractController {   
      @Autowired   
      private transient NIG225Manager nig225Manager;   
 }  

Root Cause
I forgot to add @Service to my service implementation


Solution
 @Service   
 public class NIG225ManagerImpl implements NIG225Manager {   
 }  

1 comment:

小池 said...

哈哈,我也遇過,花了一段時間去查,因為以前沒用過acuto scan ,後來還看了一下spring auto scan的作法...XD