Mybatis serverTimezone時區出現問題
錯誤信息
我們可以定位錯誤信息The server time zone value 'Öйú±ê׼ʱ¼ä' is,
則說明了是serverTimezone時區的問題
org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: 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.
### The error may exist in com/chun/dao/UserMapper.xml
### The error may involve com.chun.dao.UserMapper.getUserList
### The error occurred while executing a query
### Cause: java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time
出現原因
因為MySQL版本號是8.0以上,需要設置serverTimezone,useSSL等參數
解決
在mybatis-config.xml文件中的property name="url"在后面添加
&serverTimezone=Asia/Shanghai" //注意Shanghai是開頭大寫 或者 &serverTimezone=GMT%2B8
Mybatis 插件碰到的時區問題及用法
連接數據庫mysql -hlocalhost -uroot -p,回車,輸入密碼,回車,
show variables like'%time_zone'; (注意不要漏掉后面的分號),回車
設置時區 set time_zone = '+8:00';
以上為個人經驗,希望能給大家一個參考,也希望大家多多支持服務器之家。
原文鏈接:https://blog.csdn.net/qq_42567023/article/details/104958771