我这边出现此种报错的原因是我本地的数据在后面升级为了8.0版本的数据库,然后代码得到配置依照5.7的版本进行配置,因为升级数据库导致很多代码都出现了问题,故做此记录;希望可以帮助到大家
当我们跟换数据库后,初次启动数据库版本高低冲突导致的报错:
WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
我本地环境是8.0的MYsql 数据库故配置修改为 8.0
<mysql-connector-java.version>8.0.21</mysql-connector-java.version> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>${mysql-connector-java.version}</version> </dependency>
或者
<dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>8.0.21</version> </dependency>
修改完之后
再次启动报错:
Loading class com.mysql.jdbc.Driver'. This is deprecated. The new driver class iscom.mysql.cj.jdbc.Driver’. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
把com.mysql.jdbc.Driver修改com.mysql.cj.jdbc.Driver
我们做如下修改
加入这个
driver-class-name: com.mysql.cj.jdbc.Driver
Could not create connection to database server. Attempted reconnect 3 times. Giving up.
1、将所有的driver-class-name值都从com.mysql.jdbc.Driver修改为com.mysql.cj.jdbc.Driver(上面说过了)
2、在url的参数后面新增时区参数:&serverTimezone=UTC
3、修改url连接参数中的值更新为:zeroDateTimeBehavior=CONVERT_TO_NULL
spring: profiles: dev datasource: #url: jdbc:mysql://localhost:3306/easycode?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull url: jdbc:mysql://localhost:3306/easycode?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&serverTimezone=UTC username: root password: root filters: log4j,wall,mergeStat driver-class-name: com.mysql.cj.jdbc.Driver
注释了的是以前的;新的是修改后的;
希望可以帮助到大家;