MyBatis常见的异常及处理
1.Cause: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for
错误:匹配不了
原因:配置文件中的id方法名和dao接口中的方法名不一致
2.executor.ExecutorException: Statement returned more than one row, where no more than one was expected
错误:返回了多行
原因: 或许你想要的是一个对象,但是返回值是一个list.
解决方案:修改返回值类型
3.java.lang.IllegalStateException: SpringJUnit4ClassRunner requires JUnit 4.12 or higher
原因:版本的型号的问题,只兼容 junit 4.12 版本,切换版本即可。
4.Could not resolve type alias ‘users’. Cause: java.lang.ClassNotFoundException: Cannot find class: users
错误:类路径或者别名写错了
java.lang.IllegalStateException: Failed to load ApplicationContext
通常是因为applicationContent.xml里面的bean初始化失败的原因。或者少导入了一个jar 包。