Mybatis 查询返回List集合报错

一、问题描述 在mybatis的xml配置文件中配置select后,查询报错:Result type not match…或 Result Maps collection does not contain value for java.lang.String或 Could not find result map java.lang.String等异常。二、问题原因 1、在dao.xml文件中返回值定义为 resultType=“java.util.List” ...
Mybatis 查询返回List集合报错
一、问题描述
在mybatis的xml配置文件中配置select后,查询报错:
Result type not match…或
Result Maps collection does not contain value for java.lang.String或
Could not find result map java.lang.String等异常。

二、问题原因
1、在dao.xml文件中返回值定义为 resultType=“java.util.List” ,则dao层会报错,提示Result type not match…;

2、.xml文件中的resultMap设置成了基础数据类型(String,Integer,Double等),例如: resultMap="java.lang.String"

三、解决方法
将resultMap="java.lang.String"修改成resultType="java.lang.String" 即可。

它们之间的区别可查看以下文章:
Mybatis中的resultType和resultMap的区别2022-07-18
mengvlog 阅读 7 次 更新于 2025-07-21 08:44:57 我来答关注问题0
檬味博客在线解答立即免费咨询

报错相关话题

Copyright © 2023 WWW.MENGVLOG.COM - 檬味博客
返回顶部