首页 > 数据库技术 > 详细

spring boot连接mysql8.0

时间:2019-08-27 18:32:08      阅读:136      评论:0      收藏: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

原文:https://www.cnblogs.com/baby123/p/11419957.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!