第11讲:MyBatis中常见的异常分析

第11讲:MyBatis中常见的异常分析,第1张

大家好,我是田哥

本文是MyBatis源码分析系列文章的第11篇,本文主要内容:

常见的异常分析

下面是我给大家总结的MyBatis常见异常级原因说明。

具体内容如下:

参数名不对

Cause: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for

错误:匹配不了

原因:配置文件中的id方法名和dao接口中的方法名不一致

出现多条数据

executor.ExecutorException: Statement returned more than one row, where no more than one was expected

错误:返回了多行

原因: 或许你想要的是一个对象,但是返回值是一个list.

解决方案:修改返回值类型

版本问题

java.lang.IllegalStateException: SpringJUnit4ClassRunner requires JUnit 4.12 or higher

原因:版本的型号的问题,只兼容 junit 4.12 版本,切换版本即可。

实体类不存在

Could not resolve type alias ‘users’. Cause: java.lang.ClassNotFoundException: Cannot find class: users

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/720125.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-25
下一篇 2022-04-25

发表评论

登录后才能评论

评论列表(0条)

保存