【原因】:mybatis对应mapper文件中的 resultType 与 Dao类中声明的方法返回类型不一致。
【解决方法】:保证mapper文件中的resultType 和 Dao类中声明的方法返回类型一致。
例如Dao的方法定义为:
List<Map<String,Object>> getListById(String id);
如果mapper中的映射为
<select id="getListById" parameterType="String" resultType="java.util.List">
select id, name, age from person where id = #{id,jdbcType=VARCHAR}
</select>
则会报错,应该改为:
<select id="getListById" parameterType="String" resultType="java.util.Map">
select id, name, age from person where id = #{id,jdbcType=VARCHAR}
</select>