1、报错如下:
2020-04-22 21:27:46.931 INFO 11468 --- [ MQTT Call: aaa] com.alibaba.druid.pool.DruidDataSource : {dataSource-1} inited
Wed Apr 22 21:27:46 CST 2020 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.
2、报错原因是MySQL在高版本需要指明是否进行SSL连接:
1)、在配置的数据源url后追加如下属性,问题解决。
?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone =Asia/Shanghai
2)、旧的数据源配置如下:
spring:
datasource:
# 数据源基本配置
username: 123456
password: 123456
driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql://localhost:3306/restful_crud
type: com.alibaba.druid.pool.DruidDataSource
3)修改后的数据源配置如下:
spring:
datasource:
# 数据源基本配置
username: 123456
password: 123456
driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql://localhost:3306/restful_crud?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone =Asia/Shanghai
type: com.alibaba.druid.pool.DruidDataSource
4、常用的Mysql JDBC Url参数说明
参数名称参数说明useUnicode是否使用Unicode字符集,如果参数characterEncoding设置为gb2312或gbk,本参数值必须设置为truecharacterEncoding当useUnicode设置为true时,指定字符编码。比如可设置为gb2312或gbkuseSSL是否进行SSL连接serverTimezone设置时区时间