springboot连接mysql报错 Caused by: java.sql.SQLException: The server time zone value '�й���׼ʱ��' is unre

springboot连接mysql报错如下

Caused by: 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.

解决办法

在url中指定serverTimezone
spring.datasource.url=jdbc:mysql://localhost:3306/test?serverTimezone=GMT%2B8

原因:时区问题

//utc有8个小时时差
serverTimezone=UTC
//北京时间东八区
serverTimezone=GMT%2B8 
//或者使用上海时间
serverTimezone=Asia/Shanghai

为何没有asia/beijing时区?

你可能感兴趣的:(总结经验)