Mapped Statements collection already contains value for ... 报错原因及解决办法


一、Mapped Statements collection already contains value for…

1. 异常报错描述:

Mapped Statements collection already contains value for …
mapped 中执行SQL语句的Statements 对象的集合存在重复的值,存在于…(java.lang.IllegalArgumentException)

在这里插入图片描述

1.1 详细描述1:

Caused by: java.lang.IllegalArgumentException: Mapped Statements collection already contains value for cn.tedu.csmall.product.mapper.AlbumMapper.insert. please check file [xxx\xxx…\target\classes\mapper\AlbumMapper.xml]

mapped 中执行SQL语句的Statements 对象的集合存在重复的值,存在于 cn.tedu.csmall.product.mapper.AlbumMapper.insert 中,请检查文件 xxx\xxx...\target\classes\mapper\AlbumMapper.xml

2. 异常报错信息案例:

2.1 案例1:

在这里插入图片描述

2.1.1 异常错误描述:

错误原因:Caused by: java.lang.IllegalArgumentException: Mapped Statements collection already contains value for cn.tedu.boot08.mapper.MyProductMapper.insert. please check file [F:\JavaProjects\clone\JSD2207\t-jsd-03\boot08\target\classes\mappers\MyProductMapper.xml] and file [F:\JavaProjects\clone\JSD2207\t-jsd-03\boot08\target\classes\mappers\ProductMapper.xml]

mapped 中执行SQL语句的Statements 对象的集合存在重复的值,存在于 cn.tedu.boot08.mapper.MyProductMapper.insert 中,请检查文件 F:\JavaProjects\clone\JSD2207\t-jsd-03\boot08\target\classes\mappers\MyProductMapper.xml and [F:\JavaProjects\clone\JSD2207\t-jsd-03\boot08\target\classes\mappers\ProductMapper.xml]

2.1.2 解决方案:

解决思路:
1)这里,我们需要先根据报错信息检查报错中让我们检查的两个文件是否为同一个文件。如果为不同文件参考步骤 2 。
2)然后,我们需要再检查我们的 MyProductMapper.xmlProductMapper.xmlnamespace 的值是否重复

2.2 案例2:

在这里插入图片描述

扫描二维码关注公众号,回复: 14603613 查看本文章

2.2.1 异常错误描述:

错误原因:Caused by: java.lang.IllegalArgumentException: Mapped Statements collection already contains value for cn.tedu.csmall.product.mapper.AlbumMapper.insert. please check file [D:\IdeaProjects\clone\JSD2207\jsd2206-csmall-product-teacher\target\classes\mapper\AlbumMapper.xml] and file [D:\IdeaProjects\clone\JSD2207\jsd2206-csmall-product-teacher\target\classes\mapper\AlbumMapper.xml]

mapped 中执行SQL语句的Statements 对象的集合存在重复的值,存在于 cn.tedu.csmall.product.mapper.AlbumMapper.insert 中,请检查文件 D:\IdeaProjects\clone\JSD2207\jsd2206-csmall-product-teacher\target\classes\mapper\AlbumMapper.xml and [D:\IdeaProjects\clone\JSD2207\jsd2206-csmall-product-teacher\target\classes\mapper\AlbumMapper.xml]

2.2.2 解决方案:

解决思路:
1)这里,我们需要先根据报错信息检查报错中让我们检查的两个文件是否为同一个文件。如果为同一个文件参考步骤 2 。
2)然后,我们需要再检查我们的 AlbumMapper.xml 中的 id 为 insert 是否有重复的

在这里插入图片描述

  • 未完待续…

猜你喜欢

转载自blog.csdn.net/weixin_46030002/article/details/127064131