- 导入相关依赖
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.2.8</version>
</dependency>
- 在application.perporties全局配置文件中添加数据连接池配置
示例
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://localhost:3306/mydatabase?serverTimezone=UTC
spring.datasource.druid.username=root
spring.datasource.druid.password=123456