解決Mybatis的serverTimezone時區(qū)出現(xiàn)問題
Mybatis serverTimezone時區(qū)出現(xiàn)問題
錯誤信息
我們可以定位錯誤信息The server time zone value 'Öйú±ê׼ʱ¼ä' is,
則說明了是serverTimezone時區(qū)的問題
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
出現(xiàn)原因
因?yàn)镸ySQL版本號是8.0以上,需要設(shè)置serverTimezone,useSSL等參數(shù)
解決
在mybatis-config.xml文件中的property name="url"在后面添加
&serverTimezone=Asia/Shanghai" //注意Shanghai是開頭大寫 或者 &serverTimezone=GMT%2B8
<property name="url" value="jdbc:mysql://localhost:3306/mybatis?useSSL=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai"/>
Mybatis 插件碰到的時區(qū)問題及用法

連接數(shù)據(jù)庫mysql -hlocalhost -uroot -p,回車,輸入密碼,回車,

show variables like'%time_zone'; (注意不要漏掉后面的分號),回車

設(shè)置時區(qū) set time_zone = '+8:00';







以上為個人經(jīng)驗(yàn),希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
Java設(shè)計(jì)模式之Builder建造者模式
這篇文章主要為大家詳細(xì)介紹了Java設(shè)計(jì)模式之Builder建造者模式的相關(guān)資料,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-03-03
MyBatis 實(shí)現(xiàn)數(shù)據(jù)的批量新增和刪除的操作
這篇文章主要介紹了MyBatis 實(shí)現(xiàn)數(shù)據(jù)的批量新增和刪除的操作,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧2021-02-02
SpringBoot實(shí)現(xiàn)PDF添加水印的三種方法
本文主要介紹了SpringBoot實(shí)現(xiàn)PDF添加水印的三種方法,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2023-07-07
JAVA中時間戳與LocalDateTime互相轉(zhuǎn)換代碼例子
最近在編碼過程中遇到將時間戳轉(zhuǎn)化為 LocalDateTime,所以這里給總結(jié)下,這篇文章主要給大家介紹了關(guān)于JAVA中時間戳與LocalDateTime互相轉(zhuǎn)換的相關(guān)資料,需要的朋友可以參考下2023-11-11
簡單理解Java的垃圾回收機(jī)制與finalize方法的作用
這篇文章主要介紹了簡單理解Java的垃圾回收機(jī)制與finalize方法的作用,著重講解了Java的GC銷毀對象的過程,需要的朋友可以參考下2015-11-11

