spring boot连接mysql8.0
Posted baby123
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了spring boot连接mysql8.0相关的知识,希望对你有一定的参考价值。
今天spring boot的项目数据库从mysql5.7换到mysql8.0,遇到点问题,特此记录下来
查看mysql的版本
mysql> select version();
+-----------+
| version() |
+-----------+
| 8.0.12 |
+-----------+
修改mysql的依赖使用MySQL Connector/J
<dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>8.0.12</version> </dependency>
数据源配置
# 数据源配置,请修改为实际配置 spring.datasource.url=jdbc:mysql://localhost:3306/bim?serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=convertToNull&autoReconnect=true&useSSL=false&failOverReadOnly=false spring.datasource.username=bimengine spring.datasource.password=fgBQLZpgDaxH7xuu spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
项目启动报错
java.sql.SQLException: The connection property ‘zeroDateTimeBehavior‘ acceptable values are: ‘CONVERT_TO_NULL‘, ‘EXCEPTION‘ or ‘ROUND‘. The value ‘convertToNull‘ is not acceptable.
修改数据源配置
# 数据源配置,请修改为实际配置 spring.datasource.url=jdbc:mysql://localhost:3306/bim?serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=CONVERT_TO_NULL&autoReconnect=true&useSSL=false&failOverReadOnly=false spring.datasource.username=bimengine spring.datasource.password=fgBQLZpgDaxH7xuu spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
以上是关于spring boot连接mysql8.0的主要内容,如果未能解决你的问题,请参考以下文章
Spring Boot连接数据库,从MySql5.13飞跃到MySql8.0.18的坑
(Docker Nginx) Spring boot+Vue 前后端分离部署 详细完整版