原因:
是因為使用了Mysql Connector/J 6.x以上的版本,然后就報了時區的錯誤
遇到的問題 servertime=UTC導致時間差8個小時(MySQL jdbc 6.0 版本以上必須配置此引數)
解決方法
- 原url
jdbc.url = jdbc:mysql://localhost:3306/資料庫
- 改后的url
jdbc.url = jdbc:mysql://localhost:3306/資料庫?serverTimezone=UTC
- UTC代表的是全球標準時間 ,但是我們使用的時間是北京時區也就是東八區,領先UTC八個小時,所以使用中國標準時間,
jdbc.url = jdbc:mysql://localhost:3306/資料庫?serverTimezone=Asia/Shanghai
注意:?后面添加引數,用&連接配置多個引數
例如:jdbc.url = jdbc:mysql://localhost:3306/mybatis?serverTimezone=Asia/Shanghai&allowMultiQueries=true
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/212024.html
標籤:其他
