我使用的是Maven部署的项目,出现的异常是在target\surefire-reports\xxxx.txt这个文件中找到的,看异常的顺序是从下往上看,解决了一个问题之后再去测试一遍,一般都可以解决,再遇到其他问题的时候我会再补充这个文档,
如果小伙伴们有其他问题欢迎评论区留言,或者加我的qq:321621094交流
戳这里:
》我的另一篇文章关于搭建入门案列的详细代码《
使用IDEA搭建MyBatis入门案列遇到的一些异常
- 1、Failed to execute goal org.codehaus.mojo:exec-maven-plugin:3.0.0:exec (default-cli) on project mybatis-02: Command execution failed.
- 2、Caused by: java.io.IOException: Could not find resource com.xx.map.xxxMapper.xml
- 3、Caused by: java.lang.ClassNotFoundException: Cannot find class: User
- 4、其他问题(待收录。。。)
1、Failed to execute goal org.codehaus.mojo:exec-maven-plugin:3.0.0:exec (default-cli) on project mybatis-02: Command execution failed.
IDEA2020版本的兼容问题
- 不用main方法测试,使用junit插件,再用注解@Test测试
- 使用老版本的IDEA
2、Caused by: java.io.IOException: Could not find resource com.xx.map.xxxMapper.xml
<!--
映射文件找不到,初始化异常,未配置或错误配置mapper
注意检查核心配置文件的mapper地址,如果是resource导入的方式,则应该用/分开
多半是用了类名点
-->
<mappers>
<mapper resource="org/mybatis/example/BlogMapper.xml"/>
</mappers>
3、Caused by: java.lang.ClassNotFoundException: Cannot find class: User
<!--
这里是没找到你的实体类,resultType用全类名就可以找到了
错误写法:<select id="xx" resultType="User" parameterType="int">
-->
<mapper namespace="com.xx.map.xxxMapper">
<select id="selectUser" resultType="全类名" parameterType="int">
select * from user where id = #{id}
</select>
</mapper>
4、其他问题(待收录。。。)
> Class not found: “com.qs.map.UserMapperTest”
这错误是我习惯运行前先clean一下,然后没有deploy就运行测试文件报错的,clean之后记得先编译再运行就不会出现这个错误了