今天测试spring、springmvc、mybatis,分层为dao、service、serviceimpl、controller,在运行的时候提示
1 org.apache.catalina.core.ApplicationContext.log StandardWrapper.Throwable2 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'XXXController': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.XX.service.IXXService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@javax.annotation.Resource(shareable=true, lookup=, name=, description=, authenticationType=CONTAINER, type=class java.lang.Object, mappedName=)}3 at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:306)4 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1106)5 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)6 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
我所有的注解都已经写好的:
dao @Repository
serviceimpl @Service
controller @Controller
并且spring配置文件也写好自动扫描,位置也正确。但错误一直都在
折腾了一晚上才发现,spring监听配置被注释掉了
在web.xml里面还原spring的监听配置
12 4org.springframework.web.context.ContextLoaderListener 35 org.springframework.web.util.IntrospectorCleanupListener 6
然后问题解决了