com.alibaba.druid.pool.DruidDataSource : {dataSource-1} inited
Posted 小志的博客
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了com.alibaba.druid.pool.DruidDataSource : {dataSource-1} inited相关的知识,希望对你有一定的参考价值。
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连接:
3、解决方式:
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,本参数值必须设置为true |
characterEncoding | 当useUnicode设置为true时,指定字符编码。比如可设置为gb2312或gbk |
useSSL | 是否进行SSL连接 |
serverTimezone | 设置时区时间 |
以上是关于com.alibaba.druid.pool.DruidDataSource : {dataSource-1} inited的主要内容,如果未能解决你的问题,请参考以下文章