问题描述
Type: Exception Report
Message: Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
Description:The server encountered an unexpected condition that prevented it from fulfilling the request.
解决办法
1、有可能是因为mysql的版本是8.0以上,而程序仍然使用着com.mysql.jdbc.Driver这个驱动
要把驱动改成com.mysql.cj.jdbc.Driver
然后要更换jar包为
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>6.0.6</version>
</dependency>
2、JDBC连接Mysql6 com.mysql.cj.jdbc.Driver
, 需要指定时区serverTimezone
:
driverClassName=com.mysql.cj.jdbc.Driver
url=jdbc:mysql://localhost:3306/test?serverTimezone=UTC&useUnicode=true&characterEncoding=utf8&useSSL=false
username=root
password=
在设定时区的时候,如果设定serverTimezone=UTC
,会比中国时间早8个小时,如果在中国,可以选择Asia/Shanghai
或者Asia/Hongkong
,例如:
driverClassName=com.mysql.cj.jdbc.Driver
url=jdbc:mysql://localhost:3306/test?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false
username=root
password=