项目启动时报错: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 

这个问题纠结了我一两个小时, 百度里面的回答很多,但是每个人的错误坑不近相同,所以没能解决问题

这是一个使用Mybatis逆向工程生成的一堆文件中的一个,这个错很明显在说dao的resources包下的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.student">
    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.student">
    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>
现在再次启动服务器,就没毛病了,原理我是真的不清楚,有木有大神指导一下下呢~

      



转载于:https://www.cnblogs.com/qiyifeng/p/9746355.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值