mysql錯誤:java.sql.SQLException: The server time zone value '�й���׼ʱ��' is unrecognized or represents more than one time zone.


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.

在這里插入圖片描述

這是SpringBoot整合MySQL的依賴包版本過高,在高版本的MySQL依賴中數據庫和系統時區差異所造成的。系統為SQL默認美國時間,而我們中國要比他們遲8小時,因此將時區設置為當前系統時區即可,采用+8:00格式

兩種解決方案

1.降低 mysql-connector-java依賴版本 (使用5.1.x版本即可)

<dependency>
  <groupId>mysql</groupId>
  <artifactId>mysql-connector-java</artifactId>
  <version>5.1.35</version>
</dependency> 

2.在JDBC連接url后添加時區屬性:

&serverTimezone=GMT%2B8


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM