Error creating bean with name ‘sqlSessionFactory‘ defined in class path resource [application-dao.xm

Error creating bean with name ‘sqlSessionFactory’ defined in class path resource [application-dao.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: ‘file [D:\apache-tomcat-9.0.31\webapps\ssm_carrent\WEB-INF\classes\mapper\sys\UserMapper.xml]’; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. The XML location is ‘file [D:\apache-tomcat-9.0.31\webapps\ssm_carrent\WEB-INF\classes\mapper\sys\UserMapper.xml]’. Cause: java.lang.IllegalArgumentException: Result Maps collection already contains value for com.lg.sys.mapper.UserMapper.BaseResultMap

以上是我在用SSM框架创建项目时报的错误,由于没有抓住问题重点,一直在纠结为何“sqlSessionFactory”初始化失败,导致频繁检查和更改项目配置文件仍然没有解决报错问题。如果你在创建项目中,没有后面***Mapper文件方面的错误,可以尝试下面的方法解决问题。我们知道,SqlSession是在dao层配置文件中实现的,因此,如果这里频繁的出错,检查是否是配置文件出现了问题,检查点可参照下面两点:
(1)检查下图中的ref是否误写为value
在这里插入图片描述
(2)检查下图中的value是否误写为ref
在这里插入图片描述

以上两处对于解决我遇到的文题无用,因为我的问题重点实在*Mapper.xml文件中,仔细剖析上述报错情况,可以得到两个重点
(1)Error parsing Mapper XML
(2) Result Maps collection already contains value for com.lg.sys.mapper.UserMapper.BaseResultMap
意思就是我的XML解析存在错误,XML文件中存在重复的以“BaseResultMap” 为id的resultMap,之前没有意识到这个情况,因为xml文档并没有因为ID重复报错,究其原因是因为在使用mybatis逆向工程生成
Map文件时,执行了多次且新生成的文件并没有覆盖原文件,而是在其XML文档尾部继续添加键值对,只需把重复部分是删除即可。(我的xml文档中下面这个结果集出现了重复)
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值