使用IDEA,的MyBatis项目运行出错:Mapped Statements collection does not contain value forXX.ClassMapper.getClass

错误描述

在运行Mybatis程序时,控制台报出如下错误:
Exception in thread “main”
at com.dai.test5.Test_05.main(Test_05.java:19)
Caused by: java.lang.IllegalArgumentException:
Mapped Statements collection does not contain value
for com.dai.test5.ClassMapper.getClass
at org.apache.ibatis.session.Configuration$StrictMap.get(Configuration.java:672)
at org.apache.ibatis.session.Configuration.getMappedStatement(Configuration.java:507)
at

原因分析
在mybatis中的映射文件 Mapper.xml 中的 namespace定义错误。

解决办法
检查映射文件路径,或没有在conf.xml中进行注册,
检查定义的相关映射路径(总结:路径问题)
正确代码

##	这是在映射文件 Mapper.xml 中的 配置
<mapper namespace="com.dai.test5.ClassMapper">

相关扩展

IllegalArgumentException:此异常表明向方法传递了一个不合法或不正确的参数

  1. 非法数据异常
  2. 或者无法通过一个标识或基本扩展转换将指定值转换为基础数组的指定类型
  3. 如果位置描述为空
  4. 如果指定对象参数不是一个数组

你可能感兴趣的:(JAVA错误总结)