现在的位置: 首页 > 综合 > 正文

Injection of autowired dependencies failed;

2017年02月20日 ⁄ 综合 ⁄ 共 3125字 ⁄ 字号 评论关闭

1. 给ConfigController中添加了一个属性:

    @Autowired
    private TypeService typeService;

结果启动Tomcat时报错,

[2014-10-14 11:47:28,881] Artifact application-mobile-web:war exploded: Deploy took 6,384 milliseconds

11:47:29,842 ERROR org.springframework.web.servlet.DispatcherServlet (457) - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'configController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private
com.tcl.component.mobile.biz.service.TypeService com.tcl.application.mobile.web.controller.ConfigController.typeService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.tcl.component.mobile.biz.service.TypeService]
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:287)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1106)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:609)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:469)
at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:631)
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:588)
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:645)
at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:508)
at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:449)
at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:133)

at javax.servlet.GenericServlet.init(GenericServlet.java:160)

后面参考这篇文章时找到解决方案(http://blog.csdn.net/xb12369/article/details/38470231),我的TypeServiceImpl,少了一个@Service,添加上重新启动时就没有问题了。

抱歉!评论已关闭.