解决报错:Mapped Statements collection already contains value for...
程序员文章站
2022-07-15 12:05:52
...
这种情况通常情况下是由于Mapper映射xml文件中SQL标签的id属性重复导致的,仔细检查是否有相同的sql方法名称。
解决方法:
- 1.检查是否有重复id标签的sql;
- 2.配置项mybatis: mapper-locations:重复,导致在程序加载时,多次编译xml文件,一个方法被加载两次,就会检测到重复;
我遇到的是第二种情况,确定自己的xml确实不存在重复的sql方法名,检查到我这里的配置项重复:
mybatis:
mapper-locations:
# - classpath:mapper/single/*.xml
# - classpath:mapper/complex/*.xml
- classpath*:mapper/single/*.xml
- classpath*:mapper/complex/*.xml
这里两个配置的区别是:
classpath*:加载多模块的mapper的namespace空间;
classpath:项目中只有单个模块,使用该配置进行加载;
推荐阅读
-
使用mybatis报错【Result Maps collection already contains value for ...BaseResultMap】的解决方法
-
解决:Cause: java.lang.IllegalArgumentException: Result Maps collection already contains value for xxx
-
Mapped Statements collection already contains value for xxx
-
[email protected]使用报错:Mapped Statements collection does not contain value for XXX
-
Mybatis报错—— Mapped Statements collection does not contain value for com.mapper.DepartmentMapper
-
Mapped Statements collection already contains value for ……
-
Mapped Statements collection already contains value for
-
解决报错:Mapped Statements collection already contains value for...
-
Mapped Statements collection already contains value for xxx
-
mybatis报错Mapped Statements collection already contains value