问题:Spring与SpringMVC 的整合使用 时,出现以下问题
org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.springframework.jdbc.core.JdbcTemplate] 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)}
原因:我在两个配置文件xml中的注解扫描器扫描的包路径冲突了
<!-- 扫描器 -->
<context:component-scan base-package="pers.h.finalproject.controller"></context:component-scan>
解决方法:只要将springmvc-servlet.xml 和 applicationContext.xml中的两个扫描器扫描的包改为不相同的路径。
Spring与SpringMVC 的整合使用报错不能够自动装配
最新推荐文章于 2026-04-15 20:33:20 发布
本文介绍了一个在Spring与SpringMVC整合过程中遇到的问题,即因配置文件中注解扫描器扫描路径冲突导致的NoSuchBeanDefinitionException异常,并提供了解决方案。
7232

被折叠的 条评论
为什么被折叠?



