之前看到项目中配置数据库是spring.datasource.*
spring.datasource.url=jdbc:mysql://localhost:3306/***
spring.datasource.username=root
spring.datasource.password=12345678
spring.datasource.driver-class-name=
后来在自己负责的项目中发现是spring.datasource.druid.*
spring.datasource.druid.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.druid.url=jdbc:mysql://127.0.0.1:3306/***
spring.datasource.druid.username=root
spring.datasource.druid.password=12345678
后来自己搜索一下DruidDataSource数据源
添加依赖
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.1.20</version>
</dependency>
如果需要特定配置信息,只能使用spring.datasource.druid.*配置,具体如下:
#初始化大小
spring.datasource.druid.initial-size=5
#最大连接数
spring.datasource.druid.max-active=20
#最小连接数
spring.datasource.druid.min-idle=5
#获取连接等待超时时间
spring.datasource.druid.max-wait=10000
spring.datasource.druid.validation-query=select 1
spring.datasource.druid.validation-query-timeout=2
spring.datasource.druid.test-on-borrow=true
spring.datasource.druid.test-on-return=true
spring.datasource.druid.test-while-idle=true
#配置监控统计拦截的filters,去掉后监控界面SQL无法统计,‘wall’用于防火墙
spring.datasource.druid.filters= stat,wall