项目启动时报错:Result Maps collection already contains value for com.xxx.xxx.xx.mapper.XxxMapper.baseResult

知识养成了思想,思想同时又在融化知识。这篇文章主要讲述项目启动时报错:Result Maps collection already contains value for com.xxx.xxx.xx.mapper.XxxMapper.baseResult相关的知识,希望能为你提供帮助。
Caused by: java.lang.IllegalArgumentException:  Result Maps collection already contains value for com.xxx.xxx.xx.mapper.XxxMapper.BaseResultMap 
这个问题纠结了我一两个小时,  百度找了好久里面的回答很多,但是都没能让我理解
【项目启动时报错:Result Maps collection already contains value for com.xxx.xxx.xx.mapper.XxxMapper.baseResult】这是一个使用Mybatis逆向工程生成的一堆文件中的一个,  很多回答说是因为重复,其实我也知道是重复了,毕竟
我用刚过六级的英语水平看这句话 -- 很明显在报错的xml文件中,出现了重复的 baseResultMap 

< resultMap id="BaseResultMap" type="com.practise.pojo.Student">
< id column="id" property="id" jdbcType="BIGINT"/>
< result column="spec_name" property="specName" jdbcType="VARCHAR"/>
< /resultMap>

然后下面的引用了两次定义的这个BaseResultMap

< select id="selectByExample" resultMap="BaseResultMap" parameterType="com.practise.pojo.TbSpecificationExample">

select
< if test="distinct">
distinct
< /if>
< include refid="Base_Column_List"/>
from tb_specification
< if test="_parameter != null">
< include refid="Example_Where_Clause"/>
< /if>
< if test="orderByClause != null">
order by ${orderByClause}
< /if>
< /select>
< select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">
select
< include refid="Base_Column_List"/>
from tb_specification
where id = #{id,jdbcType=BIGINT}
< /select>

但是这两个不同的方法都得用这个返回的结果集吧 我就复制了一个ResultMap,不过换了个名字 -- 在后面家里个s,得到下面的效果

< resultMap id="BaseResultMaps" type="com.practise.pojo.Student">
< id column="id" property="id" jdbcType="BIGINT"/>
< result column="spec_name" property="specName" jdbcType="VARCHAR"/>
< /resultMap>

< resultMap id="BaseResultMap" type="com.practise.pojo.Student">
< id column="id" property="id" jdbcType="BIGINT"/>
< result column="spec_name" property="specName" jdbcType="VARCHAR"/>
< /resultMap>

< select id="selectByExample" resultMap="BaseResultMaps" parameterType="com.practise.pojo.TbSpecificationExample">

select
< if test="distinct">
distinct
< /if>
< include refid="Base_Column_List"/>
from tb_specification
< if test="_parameter != null">
< include refid="Example_Where_Clause"/>
< /if>
< if test="orderByClause != null">
order by ${orderByClause}
< /if>
< /select>
< select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">
select
< include refid="Base_Column_List"/>
from tb_specification
where id = #{id,jdbcType=BIGINT}
< /select>

现在再次启动服务器,就没毛病了,
希望大家带代码都是一次过,别像我一样搞了个把小时

项目启动时报错:Result Maps collection already contains value for com.xxx.xxx.xx.mapper.XxxMapper.baseResult

文章图片


























































    推荐阅读