You must configure either the server or JDBC driver (via the ‘serverTimezone‘ configuration property

Posted 闲言博客

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了You must configure either the server or JDBC driver (via the ‘serverTimezone‘ configuration property相关的知识,希望对你有一定的参考价值。

错误产生环境

SpringBoot项目连接mysql数据库时产生

错误描述

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.

错误原因

这是由于数据库和系统时区差异所造成的,在jdbc连接的url后面加上serverTimezone=GMT

解决办法

jdbc连接的url后面加上?serverTimezone=GMT

添加前

jdbc:mysql://localhost:3306/springboot

添加后

jdbc:mysql://localhost:3306/springboot?serverTimezone=GMT

以上是关于You must configure either the server or JDBC driver (via the ‘serverTimezone‘ configuration property的主要内容,如果未能解决你的问题,请参考以下文章