在学习Mybatis时,用IDEA配置出现一个异常,如下:
java.sql.SQLException: The server time zone value '�й���ʱ��' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the 'serverTimezone' configuration property) to use a more specifc time zone value if you want to utilize time zone support.
这是因为我的MySQL版本过高,可以选择其他版本的MySQL(可从下边的网站找对应版本)或者将application.properties中datasource改一下即可。
解决方法:
1、https://mvnrepository.com/artifact/mysql/mysql-connector-java
2、src->main->resources->application.properties
在datasource.url增加serverTimezone=UTC 参数,其中UTC是统一标准世界时间。
spring.datasource.url=jdbc:mysql://localhost:3306/test
spring.datasource.url=jdbc:mysql://localhost:3306/test?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC