首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >弹簧自动标注中的误差

弹簧自动标注中的误差
EN

Stack Overflow用户
提问于 2013-12-07 20:27:28
回答 2查看 2.1K关注 0票数 1

嗨,我在我的应用程序中得到以下错误,我无法解决它:

代码语言:javascript
复制
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是:

代码语言:javascript
复制
@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是:

代码语言:javascript
复制
@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;

更新:

嗨,仍然有同样的错误:

代码语言:javascript
复制
@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;
EN

回答 2

Stack Overflow用户

发布于 2013-12-07 20:33:00

问题是,oyu试图将豆子连接到自己身上:

代码语言:javascript
复制
//remove those 2 lines
@Autowired
protected JourneyHistoryPrepareCSVServiceImpl journeyHistoryPrepareCSVServiceImpl;

你不需要这个

票数 0
EN

Stack Overflow用户

发布于 2013-12-07 20:39:09

您在哪里定义了com.novacroft.nemo.tfl.common.application_service.JourneyHistoryService类型的bean?

仔细查看堆栈跟踪:)

代码语言:javascript
复制
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)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20446222

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档