spring注入失败,有点绝望了,希望老师能帮我一下,感谢

来源:5-14 spring、springmvc配置实操

Mark1900

2018-12-28

下面是具体的报错信息。

org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘userManageController’: Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: public com.mmall.service.IUserService com.mmall.controller.backend.UserManageController.iUserService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘iUserService’: Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.mmall.dao.UserMapper com.mmall.service.impl.UserServiceImpl.userMapper; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘userMapper’ defined in file [/home/xiao/IdeaProjects/mmall/target/mmall/WEB-INF/classes/com/mmall/dao/UserMapper.class]: Unsatisfied dependency expressed through bean property ‘sqlSessionFactory’: : Error creating bean with name ‘sqlSessionFactory’ defined in class path resource [applicationContext-datasource.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: ‘file [/home/xiao/IdeaProjects/mmall/target/mmall/WEB-INF/classes/mappers/CategoryMapper.xml]’; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: java.lang.IllegalArgumentException: Result Maps collection already contains value for com.mmall.dao.CategoryMapper.BaseResultMap; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘sqlSessionFactory’ defined in class path resource [applicationContext-datasource.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: ‘file [/home/xiao/IdeaProjects/mmall/target/mmall/WEB-INF/classes/mappers/CategoryMapper.xml]’; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: java.lang.IllegalArgumentException: Result Maps collection already contains value for com.mmall.dao.CategoryMapper.BaseResultMap

然后我的配置文件:
图片描述
图片描述
<context:component-scan base-package=“com.mmall” annotation-config=“true”/>

代码的话:
图片描述
图片描述

图片描述

写回答

2回答

Geely

2019-01-03

看报错应该是重复节点了。


你的CategoryMapper.xml有问题,Result Maps collection already contains value for com.mmall.dao.CategoryMapper.BaseResultMap,


同学检查一下

0
0

geelylucky

2018-12-28

同学,你好,我是geely老师的助教。

具体问题出在Failed to parse mapping resource: ‘file [/home/xiao/IdeaProjects/mmall/target/mmall/WEB-INF/classes/mappers/CategoryMapper.xml]’

你的CategoryMapper.xml有问题,Result Maps collection already contains value for com.mmall.dao.CategoryMapper.BaseResultMap,

请同学查看以下BaseResultMap。

希望能帮助到你。

0
1
Geely
看报错应该是重复节点了。
2019-01-03
共1条回复

从0开始 独立完成企业级Java电商网站服务端开发

前后端分离,数据库接口设计,架构设计,功能开发,上线运维

9476 学习 · 8804 问题

查看课程