2013-12-07 78 views
1

你好我得到我的應用程序下面的錯誤,我無法來解決它:錯誤春季自動裝配註解

ERROR localhost-startStop-1 org.springframework.web.context.ContextLoader - Context initialization failed 
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'journeyHistoryCSVServiceImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: 
    com.common.application_service.impl.JourneyHistoryPrepareCSVServiceImpl com..common.application_service.impl.JourneyHistoryCSVServiceImpl.journeyHistoryPrepareCSVServiceImpl; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'journeyHistoryPrepareCSVServiceImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: protected com.common.application_service.JourneyHistoryService com.common.application_service.impl.JourneyHistoryPrepareCSVServiceImpl.journeyHistoryService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'journeyHistoryServiceImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.common.application_service.JourneyHistoryService com.common.application_service.impl.JourneyHistoryServiceImpl.journeyHistoryService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.common.application_service.JourneyHistoryService] 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.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:288) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1116) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458) 
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295) 
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) 
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:626) 
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932) 
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479) 
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389) 

journeyHistoryCSVServiceImpl是:

@Service("journeyHistoryCSVServiceImpl") 
public class JourneyHistoryCSVServiceImpl implements JourneyHistoryCSVService { 
    static final Logger logger = LoggerFactory.getLogger(JourneyHistoryCSVServiceImpl.class); 

    @Autowired 
    protected JourneyHistoryPrepareCSVServiceImpl journeyHistoryPrepareCSVServiceImpl; 
    @Autowired 
    protected ApplicationContext applicationContext;  
    @Autowired 
    protected JourneyHistoryServiceImpl journeyHistoryServiceImpl; 

和我JourneyHistoryPrepareCSVServiceImpl是:

@Service("journeyHistoryPrepareCSVServiceImpl") 
public class JourneyHistoryPrepareCSVServiceImpl extends AbstractBaseService implements JourneyHistoryPrepareCSVService { 
    static final Logger logger = LoggerFactory.getLogger(JourneyHistoryPrepareCSVServiceImpl.class); 

    @Autowired 
    protected JourneyHistoryService journeyHistoryService; 
    @Autowired 
    protected SystemParameterService systemParameterService; 

更新:

嗨仍然得到同樣的錯誤:

@Service("journeyHistoryCSVServiceImpl") 
public class JourneyHistoryCSVServiceImpl implements JourneyHistoryCSVService { 
    static final Logger logger = LoggerFactory.getLogger(JourneyHistoryCSVServiceImpl.class); 

    @Autowired 
    protected JourneyHistoryPrepareCSVServiceImpl journeyHistoryPrepareCSVServiceImpl; 
    @Autowired 
    protected ApplicationContext applicationContext;  
    @Autowired 
    protected JourneyHistoryService journeyHistoryService; 
+0

嗨,我仍然得到這個錯誤: – user3033031

+0

您試圖自動裝配'JourneyHistoryService'並在上下文中沒有bean實現了這個接口。這是堆棧跟蹤所告知的。 也許你應該首先在紙上繪製bean依賴關係。所以giusy的問題是相當合理的。 –

回答

0

的問題是,奧尤嘗試豆絲本身:

//remove those 2 lines 
@Autowired 
protected JourneyHistoryPrepareCSVServiceImpl journeyHistoryPrepareCSVServiceImpl; 

你不需要這個

0

在哪裏你有沒有定義類型爲com.novacroft.nemo.tfl.common.application_service.JourneyHistoryService的bean?

仔細查看堆棧跟蹤:)

nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: 
No qualifying bean of type [com.novacroft.nemo.tfl.common.application_service.JourneyHistoryService] 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.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:288) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1116) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458) 
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295) 
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) 
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:626) 
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932) 
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479) 
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389)