在项目中使用阿里的druid连接池,pom文件配置:
mysql
mysql-connector-java
runtime
com.alibaba
druid-spring-boot-starter
1.1.14
application.properties配置,官方文档可查:
# Druid连接池配置,官方配置参考:https://github.com/alibaba/druid/tree/master/druid-spring-boot-starter
spring.datasource.url=jdbc:mysql://localhost:3306/test?serverTimezone=Asia/Shanghai
spring.datasource.username=root
spring.datasource.password=123456
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
# Druid其他配置
spring.datasource.druid.initial-size=5
spring.datasource.druid.max-active=20
spring.datasource.druid.min-idle=10
spring.datasource.druid.max-wait=10
spring.datasource.druid.filters=stat,wall</