我是靠谱客的博主 冷静战斗机,最近开发中收集的这篇文章主要介绍解决Mybatis的serverTimezone时区出现问题,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

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
 <property name="url" value="jdbc:mysql://localhost:3306/mybatis?useSSL=true&amp;useUnicode=true&amp;characterEncoding=UTF-8&amp;serverTimezone=Asia/Shanghai"/>

Mybatis 插件碰到的时区问题及用法

连接数据库mysql -hlocalhost -uroot -p,回车,输入密码,回车,

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

设置时区 set time_zone = '+8:00';

以上为个人经验,希望能给大家一个参考,也希望大家多多支持靠谱客。

最后

以上就是冷静战斗机为你收集整理的解决Mybatis的serverTimezone时区出现问题的全部内容,希望文章能够帮你解决解决Mybatis的serverTimezone时区出现问题所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(112)

评论列表共有 0 条评论

立即
投稿
返回
顶部