在运行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:此异常表明向方法传递了一个不合法或不正确的参数