Gradle 配置 Druid 数据源
目录
- 添加依赖
compile ‘com.alibaba:druid-spring-boot-starter:1.1.20’
注意降级了!最新是21,但有bug。
InteIliJ IDEA 2019.3.3 (Ultimate Edition) + jdk 13.0.2 + apache maven 3.6.3
- 添加配置
spring.datasource.druid.url= # 或spring.datasource.url=
spring.datasource.druid.username= # 或spring.datasource.username=
spring.datasource.druid.password= # 或spring.datasource.password=
spring.datasource.druid.driver-class-name= #或 spring.datasource.driver-class-name=
一个简单的示例:
spring.datasource.username=spas
spring.datasource.password=Passw0rd!
spring.datasource.url=jdbc:mysql://${user.host}:3306/spas?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=UTC
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
更多问题探索:
如何获取 Druid 的监控数据
Druid 支持 jdk 8,高版本可能会出错。
Spring Boot教程(七):Spring Boot集成druid连接池
【WARNING】The POM for com.alibaba:druid:jar:1.1.21 is invalid 警告问题