第一步:我的web.xml用通配符加载了所有的配置文件![](https://imgsa.baidu.com/forum/w%3D580/sign=f4903e4b61600c33f079dec02a4d5134/0ec53f2ac65c1038ccb0339db8119313b17e893d.jpg)
第二步:配置好连接数据库需要的参数
![](https://imgsa.baidu.com/forum/w%3D580/sign=1b9f7ee0865494ee87220f111df4e0e1/2b2a6681800a19d8547f7b5a39fa828ba71e4683.jpg)
第三步:配置基本的application.xml.导入连接数据库参数和扫描service包
![](https://imgsa.baidu.com/forum/w%3D580/sign=14296a8302fa513d51aa6cd60d6c554c/8cf6fc246b600c3302e22197104c510fd8f9a168.jpg)
第四步:配置扫描mapper和mapper.xml
![](https://imgsa.baidu.com/forum/w%3D580/sign=193039bc5d2c11dfded1bf2b53266255/77c79222720e0cf3ac23b0a40046f21fbf09aa2b.jpg)
第五步:以下是service、service,impl、mapper、mapper.xml
![](https://imgsa.baidu.com/forum/w%3D580/sign=719da85706d79123e0e0947c9d355917/9c795ee736d12f2e0225563f45c2d562843568e7.jpg)
![](https://imgsa.baidu.com/forum/w%3D580/sign=e2afcf2072f0f736d8fe4c093a54b382/618d3c7adab44aed67b847bbb91c8701a08bfb15.jpg)
![](https://imgsa.baidu.com/forum/w%3D580/sign=675de2b2a9cc7cd9fa2d34d109002104/7a83f7faaf51f3de7f7d403b9eeef01f3b29793c.jpg)
![](https://imgsa.baidu.com/forum/w%3D580/sign=459e7f76e1c4b7453494b71efffd1e78/54898d01a18b87d668b452400d0828381e30fd15.jpg)
第六步:我的test类
![](https://imgsa.baidu.com/forum/w%3D580/sign=8b05243f3f2ac65c6705667bcbf3b21d/aca3a6af2edda3cccd5b407f0be93901203f924c.jpg)
第七步:我报错的内容
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'luoxu.UserTest': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.lx.service.UserService luoxu.UserTest.userService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.lx.service.UserService] 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)}
第八步:我感觉就是mapper一直注入不成功,我也是在学习搭建ssh框架,所以确实找不到问题在哪儿了,麻烦大家帮我看看,非常感谢,都纠结2两天了。
![](https://imgsa.baidu.com/forum/w%3D580/sign=f4903e4b61600c33f079dec02a4d5134/0ec53f2ac65c1038ccb0339db8119313b17e893d.jpg)
第二步:配置好连接数据库需要的参数
![](https://imgsa.baidu.com/forum/w%3D580/sign=1b9f7ee0865494ee87220f111df4e0e1/2b2a6681800a19d8547f7b5a39fa828ba71e4683.jpg)
第三步:配置基本的application.xml.导入连接数据库参数和扫描service包
![](https://imgsa.baidu.com/forum/w%3D580/sign=14296a8302fa513d51aa6cd60d6c554c/8cf6fc246b600c3302e22197104c510fd8f9a168.jpg)
第四步:配置扫描mapper和mapper.xml
![](https://imgsa.baidu.com/forum/w%3D580/sign=193039bc5d2c11dfded1bf2b53266255/77c79222720e0cf3ac23b0a40046f21fbf09aa2b.jpg)
第五步:以下是service、service,impl、mapper、mapper.xml
![](https://imgsa.baidu.com/forum/w%3D580/sign=719da85706d79123e0e0947c9d355917/9c795ee736d12f2e0225563f45c2d562843568e7.jpg)
![](https://imgsa.baidu.com/forum/w%3D580/sign=e2afcf2072f0f736d8fe4c093a54b382/618d3c7adab44aed67b847bbb91c8701a08bfb15.jpg)
![](https://imgsa.baidu.com/forum/w%3D580/sign=675de2b2a9cc7cd9fa2d34d109002104/7a83f7faaf51f3de7f7d403b9eeef01f3b29793c.jpg)
![](https://imgsa.baidu.com/forum/w%3D580/sign=459e7f76e1c4b7453494b71efffd1e78/54898d01a18b87d668b452400d0828381e30fd15.jpg)
第六步:我的test类
![](https://imgsa.baidu.com/forum/w%3D580/sign=8b05243f3f2ac65c6705667bcbf3b21d/aca3a6af2edda3cccd5b407f0be93901203f924c.jpg)
第七步:我报错的内容
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'luoxu.UserTest': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.lx.service.UserService luoxu.UserTest.userService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.lx.service.UserService] 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)}
第八步:我感觉就是mapper一直注入不成功,我也是在学习搭建ssh框架,所以确实找不到问题在哪儿了,麻烦大家帮我看看,非常感谢,都纠结2两天了。