springboot工程无法连接数据库 The server time zone value ‘�й���׼ʱ��‘ is unrecognized or represents..._the server timezone is <?泄???准时?> that's unknown-程序员宅基地

技术标签: spring boot  BUG  mysql  springboot  

创建springboot框架创建SSM项目。发现无法获取数据库内容,报错如下:

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.

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
###Error querying database. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is 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 file [D:\sss\mysprintbootall\sprint-boot-parent\sprint-boot-user\target\classes\mappers\userMapper.xml]

###The error may involve com.zb.mapper.userMaper.queryUserById
###The error occurred while executing a query
###Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is 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.

问题造成的原因是:
spring-boot-starter-parent 1.5.9.RELEASE2.2.5.RELEASE依赖的mysql-connect-java的版本不同。2.2.5版本的mysql-connect的版本超过6.0。

<parent>
        <artifactId>spring-boot-starter-parent</artifactId>
        <groupId>org.springframework.boot</groupId>
        <version>2.2.5.RELEASE</version>
</parent>

针对超过6.0的版本。配置application.properties的文件,有几点不同:
1.datasource.driver-class不是com.mysql.jdbc.Driver而是com.mysql.cj.jdbc.Driver.
2.在连接数据库的url后面,要添加一个servertime=

server.port=8080
#server.servlet.context-path=/spring-boot-user
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/zb_database?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
spring.datasource.username=root
spring.datasource.password=root

mybatis.mapper-locations=classpath:mappers/*.xml
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/zhouben12/article/details/107360566

智能推荐

%d输出float类型,%f输出int类型_int型能用%f输出吗-程序员宅基地

文章浏览阅读3.6k次,点赞3次,收藏22次。// 输出格式与类型不一致,输出结果实际上与存储有关 // 1.int以%f格式输出,结果一般为0.000000 // 2.long long 类型的很大的数,用printf(“%f”)打印出来可能为一个小数; // 3.double、float以%d格式输出(输出时,float会转化为double存储形式;%d取低32位) // (1)结果一般为绝对值很大的数(当浮点数不能精确表示时,低32位不为0) // _int型能用%f输出吗

目标检测标注数据的检查和可视化_目标标注信息统计可视化-程序员宅基地

文章浏览阅读4.6k次。标注数据是一件十分枯燥的重复性工作。在标注数据时,有时因为数据量大,类别多,会出现错标、误标的情况,这时就需要对标注数据进行检查并且修改。_目标标注信息统计可视化

flutter 项目实践2_jj2d.top-程序员宅基地

文章浏览阅读2.5k次。本片文章来自与我自己的有道云笔记 要看图片请点击链接文档:Day 4_3 项目实践2.md链接:http://note.youdao.com/noteshare?id=f28e3058fea4d26f1b32bdc21f1a220c&sub=A3757D0FAF4C4BC29A8CF2E6F1C8DBD6上次做了什么我们把框架搭好了IndexedStack 分开了基础的页面制作了简单的首页 读取json文件 然后展示我们的首页基本就算制作完了然后我们想做一些展示home_cont_jj2d.top

elasticsearch-head连接问题_elasticsearch 开启xpack head如何连接-程序员宅基地

文章浏览阅读2.8k次。场景:最近打算使用elasticsearch做日志搜索,使用elasticsearch-head作为一个图形化界面查看index、type、document信息。elasticsearch 7.14.1mobz/elasticsearch-head:5地址:https://github.com/mobz/elasticsearch-head看完这个readme文档后,计划使用docker方式进行部署。1.更改elasticsearch.yml文件,包括xpack等配置,示例如下:_elasticsearch 开启xpack head如何连接

Selenium 根据元素文本内容定位_selenium java根据文字定位-程序员宅基地

文章浏览阅读1.8k次。使用xpath定位元素时,有时候担心元素位置会变,可以考虑使用文本内容来定位的方式。例如图中的【评价】按钮,只有按钮文本没变,就可以定位到该元素。_selenium java根据文字定位

Linux中设置固定ip的方法_linux设置固定ip-程序员宅基地

这篇文章介绍了在Linux中设置固定IP的方法,包括使用ifconfig命令查看网络状态、使用ping命令检查网络连接、修改网络配置文件和管理防火墙。

随便推点

浙大 PAT 甲级 1077 Kuchiguse_pat甲级可以用翻译吗-程序员宅基地

文章浏览阅读135次。读题目真是要笑死我了…太不正经了。很简单的20分~将题意翻译成代码即可。#include<iostream>#include<string>using namespace std;int main(){ int N; scanf("%d", &N); getchar(); string base; getlin..._pat甲级可以用翻译吗

centos7 svn服务器搭建_svn co authentication方法-程序员宅基地

文章浏览阅读1.5k次。基于centos7 的svn服务器配置_svn co authentication方法

capilot激活时遇到Sign in failed: Error: network error_sign in failed. reason: could not log in with devi-程序员宅基地

文章浏览阅读922次。capilot激活遇到问题,Sign in failed: Error: network error_sign in failed. reason: could not log in with device flow on cocopilot.org:

mysql 存储过程 序列_Oracle 生成序列号存储过程-程序员宅基地

文章浏览阅读147次。项目中经常要根据年月日规则生成序列号,简单写了个存储过程可根据需要扩展 一、序列号存储表 -- Create tablecreate table SYS_项目中经常要根据年月日规则生成序列号,简单写了个存储过程可根据需要扩展一、序列号存储表-- Create tablecreate table SYS_GENKEY(DATESTR VARCHAR2(50),MAXCOUNT NUMBER,TYP..._mysql 存储过程 序号

java tools.jar包含_无法找到tools.jar-程序员宅基地

文章浏览阅读583次。如果对任何人来说这仍然是一个问题,我对之前的答案有一点澄清。我使用只安装了JDK的ant遇到了同样的问题。虽然,JDK安装程序给了我一个这样的目录结构:Directory of C:\Program Files\Java05/08/2012 09:43 AM .05/08/2012 09:43 AM ..05/08/2012 09:46 A...

阿里云服务器一直提示安全事件如何解决_云服务安全提示什么意思-程序员宅基地

文章浏览阅读1.9k次。阿里云服务器一直发送短信提醒安全事件导致服务器中的然和程序都无法访问的时候该如何处理_云服务安全提示什么意思

推荐文章

热门文章

相关标签