idea运行mybatis出现Exception in thread "main" org.apache.ibatis.exceptions.PersistenceException等相关问题解决方案

idea运行mybatis出现Exception in thread “main” org.apache.ibatis.exceptions.PersistenceException等相关问题解决方案


最近,在跟着黑马IT的视频学习mybatis,第一个案例出现了一系列的问题,现记录如下


问题1:Error:java: 错误: 不支持发行版本 5

我的jdk时13.03版本的,所以需要将三个地方设置的相同

文件->项目结构
idea运行mybatis出现Exception in thread "main" org.apache.ibatis.exceptions.PersistenceException等相关问题解决方案
idea运行mybatis出现Exception in thread "main" org.apache.ibatis.exceptions.PersistenceException等相关问题解决方案
第三个地方:文件->设置
idea运行mybatis出现Exception in thread "main" org.apache.ibatis.exceptions.PersistenceException等相关问题解决方案
idea运行mybatis出现Exception in thread "main" org.apache.ibatis.exceptions.PersistenceException等相关问题解决方案
把红色圈圈的地方与上方版本设置成一致,此处为13


问题2:这也是比较难发现的问题:Exception in thread “main” org.apache.ibatis.exceptions.PersistenceException

1.首先关注目录src/main/resources文件夹下的SqlMapConfig.xml文件

idea运行mybatis出现Exception in thread "main" org.apache.ibatis.exceptions.PersistenceException等相关问题解决方案
如果你的mysql时8.0以上的版本,有两个地方需要修改:
idea运行mybatis出现Exception in thread "main" org.apache.ibatis.exceptions.PersistenceException等相关问题解决方案
MySQL 8.0 以上版本 - JDBC 驱动名及数据库 URL:

com.mysql.cj.jdbc.Driver

jdbc:mysql://localhost:3306/runoob?useSSL=false&serverTimezone=UTC

URL中的runoob是我自己建立的数据库的名称。

2.关注版本对应问题,这个也是比较难发现的点

将pom.xml文件夹下的mysql-connector-java更换一下版本号至8.0.16idea运行mybatis出现Exception in thread "main" org.apache.ibatis.exceptions.PersistenceException等相关问题解决方案
我之前很难找出的一个问题就是这里。

改完之后问题完美解决。
运行结果如下:
idea运行mybatis出现Exception in thread "main" org.apache.ibatis.exceptions.PersistenceException等相关问题解决方案