springBoot项目-mysql时区问题

87 阅读1分钟
  • error

Caused by: com.mysql.cj.exceptions.InvalidConnectionAttributeException: 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.

image.png

原因:在连接 MySQL 数据库时,遇到了无法识别或表示多个时区的服务器时区值。为了正确使用时区支持,你需要通过配置服务器或 JDBC 驱动器来使用更具体的时区值。

加上 serverTimezone=UTC 即可

image.png