連接數據庫時顯示:
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, 再次輸入: show variables like '%time_zone%';
如果還是顯示time_zone | SYSTEM
可能是由於還沒有更新緩存導致的, 再次輸入: set time_zone='+8:00';
set global time_zone = ‘+8:00‘; ##修改mysql全局時區為北京時間,即我們所在的東8區 set time_zone = ‘+8:00‘; ##修改當前會話時區 flush privileges; #立即生效
如果顯示Query Ok, 0 rows affected, 那么很可能是已經更新時區成功了
如果以上方法還不可以解決問題, 那么嘗試在代碼中做調整
jdbc:mysql://127.0.0.1:3306/onestep?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&useSSL=false&serverTimezone=GMT%2B8
重啟服務和應用即可