- 添加依赖:
<!-- druid 连接池 -->
<!-- https://mvnrepository.com/artifact/com.alibaba/druid -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.1.22</version>
</dependency>
- 添加配置
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
spring.datasource.druid.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.druid.url=jdbc:mysql://127.0.0.1:3306/***?serverTimezone=UTC&useUnicode=true&characterEncoding=UTF-8
spring.datasource.druid.username=root
spring.datasource.druid.password=root
# 初始化连接数大小
spring.datasource.druid.initial-size=5
# 最小连接数
spring.datasource.druid.min-idle=3
# 最大连接数
spring.datasource.druid.max-active=10
# 连接超时时间
spring.datasource.druid.max-wait=60000