Result Maps collection already contains value for xxx

简介:

项目中使用了MyBatis,启动后控制台输出错误:

Caused by: java.lang.IllegalArgumentException: Result Maps collection already contains value for com.xxx.xxxResultMap
    at org.apache.ibatis.session.Configuration$StrictMap.put(Configuration.java:872) ~[mybatis-3.4.5.jar:3.4.5]
    at org.apache.ibatis.session.Configuration$StrictMap.put(Configuration.java:844) ~[mybatis-3.4.5.jar:3.4.5]
    at org.apache.ibatis.session.Configuration.addResultMap(Configuration.java:626) ~[mybatis-3.4.5.jar:3.4.5]
    at org.apache.ibatis.builder.MapperBuilderAssistant.addResultMap(MapperBuilderAssistant.java:214) ~[mybatis-3.4.5.jar:3.4.5]
    at org.apache.ibatis.builder.ResultMapResolver.resolve(ResultMapResolver.java:47) ~[mybatis-3.4.5.jar:3.4.5]
    at org.apache.ibatis.builder.xml.XMLMapperBuilder.resultMapElement(XMLMapperBuilder.java:285) ~[mybatis-3.4.5.jar:3.4.5]
    at org.apache.ibatis.builder.xml.XMLMapperBuilder.resultMapElement(XMLMapperBuilder.java:252) ~[mybatis-3.4.5.jar:3.4.5]
    at org.apache.ibatis.builder.xml.XMLMapperBuilder.resultMapElements(XMLMapperBuilder.java:244) ~[mybatis-3.4.5.jar:3.4.5]
    at org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement(XMLMapperBuilder.java:116) ~[mybatis-3.4.5.jar:3.4.5]
    ... 34 common frames omitted

错误原因:
这个错误产生的原因是因为使用 MyBatis Generator 生成代码,包括:Model、Dao、Mapping 时,配置文件中把注释去掉了,这就导致重复生成的时候,文件中的内容也会产生重复。

解决方法:
1、MyBatis Generator 配置中启用注释;
2、重复生成时先删除之前生成的文件;
3、手动删除生成后的重复内容(不推荐,因为内容比较多,比较麻烦);

目录
相关文章
|
存储 JSON 对象存储
|
7月前
|
SQL IDE Java
hibernate5 Cannot create TypedQuery for query with more than one return using requested result type
hibernate5 Cannot create TypedQuery for query with more than one return using requested result type
78 0
|
15天前
|
算法
你对Collection中Set、List、Map理解?
你对Collection中Set、List、Map理解?
52 18
你对Collection中Set、List、Map理解?
|
缓存
source-map
webpack 配置 source-map
118 0
source-map
|
存储 JavaScript 前端开发
ES6 中 Map 和 Set
ES6 中 Map 和 Set
103 0
Could not resolve element type of Iterable type xxxxx.RequestParam java.util.List<?>. Not declared?
Could not resolve element type of Iterable type xxxxx.RequestParam java.util.List<?>. Not declared?
Could not resolve element type of Iterable type xxxxx.RequestParam java.util.List<?>. Not declared?
|
JSON 缓存 JavaScript
一文了解source-map
一文了解source-map
|
Java Maven 数据库
Eclipse出现Result Maps collection already contains value for “XXX”问题
Eclipse出现Result Maps collection already contains value for “XXX”问题
149 0
|
Java 数据库连接 mybatis
A query was run and no Result Maps were found for the Mapped Statement
A query was run and no Result Maps were found for the Mapped Statement
225 0

热门文章

最新文章