Skip to content

Latest commit

 

History

History
69 lines (44 loc) · 1.68 KB

File metadata and controls

69 lines (44 loc) · 1.68 KB

spring boot 适配 MyLSQ 8.0

当前(2018-10-28)最新版的 Spring boot 版本为 2.0.6.RELEASE,其中关于 MySQL 的驱动版本为 5.1.47,该版本不支持当前最新的 MySQL 8.0,需要手动设置 MySQL 驱动的版本,否则无法连接。

需要改动的地方如下:

项目的 pom.xml 文件:

../pom.xml

        <!-- mysql -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.13</version>
            <scope>runtime</scope>
        </dependency>

版本必须在 8.0 以上,否则无法支持 MySQL 8.0 及以上版本的连接

配置文件 application.yml:

## spring config
spring:
  # datasource connect-pool
  datasource:
    druid:
      type: com.alibaba.druid.pool.DruidDataSource
      driver-class-name: com.mysql.cj.jdbc.Driver
      initial-size: 5
      max-active: 20
      max-wait: 60000
      time-between-eviction-runs-millis: 60000
      min-evictable-idle-time-millis: 300000

原来配置 MySQL 的驱动为: com.mysql.jdbc.Driver

新的 MySQL 驱动配置为: com.mysql.cj.jdbc.Driver

这个问题一般出现在 spring boot 项目代码迁移时,由于新的环境 MySQL 数据库的版本过高导致项目运行抛错

本次提交记录为:

commit 9591a8fc172f5a759e580be8a83615a91aeb3d15 (HEAD -> dev, origin/master, origin/dev, master)
Author: ljq <flying9001@gmail.com>
Date:   Sun Oct 28 12:01:25 2018 +0800

    解决 spring boot 项目适配 mysql 8.0+ 问题

git 版本回退命令:

git reset --soft 9591a8fc172f5a759e580be8a83615a91aeb3d15