淘淘商城Spring注入报错求大神帮看看啊!!!
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'itemController': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.taotao.service.ItemService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@javax.annotation.Resource(type=class java.lang.Object, mappedName=, shareable=true, lookup=, authenticationType=CONTAINER, description=, name=)}
web.xml中没有引入applicactionContext-service.xml
改成classpath:spring/*.xml
把所有的@Resource改成@Autowired注入
然后再看看导包有没有导错
检查一下mapper对应的xml,在检查一下注解的包有没有倒错
web.xml少引入了spring容器applicationContext-*
加入这段代码
<!-- 加载spring容器 -->
contextConfigLocation
/WEB-INF/classes/spring/applicationContext-*.xml
还有@Resource改成@Autowired注入试试可以不
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring/applicationContext-*.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
之前我也遇到过这个问题,因为我用的idea +maven 我把iml文件清掉重新导入项目,就可以了。你可以尝试一下,重新导入项目
日志复制完了吗,itemMapper有没有报错
ItemServiceImpl在哪个包下, 是不是没有扫到?
1.此maven分支项目要在pom.xml 文件引入service模块的jar或者service模块的maven坐标,使用eclipse maven update 更新一下项目
2.在web.xml中添加spring监听器配置
contextConfigLocation
classpath:spring/applicationContext-*.xml
org.springframework.web.context.ContextLoaderListener