问题描述
我在使用mybatis批量注入时,我的对应mapper中的方法如下所示
Integer batchInsert(List<AnalysisResult> resultList);
其中的参数名为resultList,对应的xml中的collection命名也为:resultList
<insert id="batchInsert" parameterType="java.util.List">
insert into test(area_name, city_name, city_code) VALUES
<foreach collection="resultList" item="result" index="index" separator=",">
(#{result.area_name}, #{result.city_name}, #{result.city_code})
</foreach>
</insert>
这时执行批量插入时就会出现如下错误
org.apache.ibatis.binding.BindingException: Parameter 'resultList' not found. Available parameters are [collection, list]
解决办法之一
将mapper中的参数改成list,对应xml中的collection也改成list,即可解决上述问题
其具体原因还没有搞懂,若有人知道,希望留言指导下。