Exception in thread "main" org.apache.ibatis.exceptions.PersistenceException
在使用mybatis開發的時候,會出現如下異常
這是因為我們沒有正确的配置資料庫的驅動和連接配接資訊。
對于8.0以上的MySql資料庫,需要在mybatis的主配置檔案中修改下面兩個資訊
首先是在driver的value中加入cj
其次是在url的後面加入如下代碼
useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone = GMT
但是在xml中,需要使用&來表示&
是以需要改變以下兩行代碼
但是在xml中,&符号實際用&來表示
是以需要改變兩行
<property name="driver" value="com.mysql.cj.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/databa?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone = GMT"/>
同時也要在pom檔案中将mysql-connector-java的版本号更新
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.23</version>
</dependency>
修改之後重新運作問題就已經得到解決了