Result Maps collection does not contain value for java.lang.Integer异常处理

使用Mybatis的时候出现这个问题是因为配置文件的问题造成的,mybatis需要写大量的配置文件,

尽管有mybatis-generator,但是里面的内容有很多还是要自己去写的,在这过程中难免会出现问题,

上述问题是因为返回类型错误造成的,resultMap属性的返回类型错误,如下

<select id="getListBy" parameterType="com.cbt.staticize.model.Intensve" resultMap="java.lang.Integer">
    select 
    <include refid="Base_Column_List"/>
    from intensve where valid=1 and word!="" and word is not null
    <include refid="basesql"/>
  </select>

把其中的resultMap="java.lang.Integer"改为对应的返回类型,如<resultMap id="BaseResultMap"...>,则改为resultMap="BaseResultMap"即可。

注意:该错误不会指向某个xml,只要任一配置文件出错,运行程序均会报该错误,所以只能逐个mapper.xml查找。可利用eclipse的全局文本搜索进行排除

原文地址:https://www.cnblogs.com/xiao-tao/p/6052328.html