Configuration of springboot + Druid connection pool

# These 4 parameters key without druid can also be used, that is, you can also use the above 4 parameters
spring.datasource.druid.url=jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=UTC
spring.datasource.druid.username=root
spring.datasource.druid.password=123456
spring.datasource.druid.driver-class-name=com.mysql.jdbc.Driver

# The number of physical connections established at initialization
spring.datasource.druid.initial-size=5
# Maximum number of connection pools
spring.datasource.druid.max-active=30
# Minimum number of connection pools
spring.datasource.druid.min-idle=5
# Maximum wait time in milliseconds when getting a connection timeout link timeout
spring.datasource.druid.max-wait=60000
# Configure how long between detections for idle connections that need to be closed, in milliseconds Timeout for detecting non-core links
# Both as the interval for detection and as the basis for testWhileIdel execution
spring.datasource.druid.time-between-eviction-runs-millis=60000
# Minimum time for a connection to remain idle and not be evicted
spring.datasource.druid.min-evictable-idle-time-millis=300000
# The sql used to check if the connection is valid, requires a query statement 8 hour question 8 hours without communication with mysql mysql will actively close the link
spring.datasource.druid.validation-query=SELECT 1 FROM DUAL
# It is recommended to configure to true to not affect performance and to ensure security. detects when a connection is requested.
# If idle time is greater than min-evictable-idle-time-millis, execute validationQuery to check if the connection is valid.
spring.datasource.druid.test-while-idle=true
# Execute validationQuery when requesting a connection to check if the connection is valid.
spring.datasource.druid.test-on-borrow=false
# Execute validationQuery when returning a connection to check if the connection is valid.
spring.datasource.druid.test-on-return=false
# Whether to cache the preparedStatement, or PSCache, which is a huge performance boost for databases that support cursors, such as oracle.
# For example, oracle. it is recommended to turn it off under mysql. Not mysql side, link side, select * from student query cache

spring.datasource.druid.pool-prepared-statements=true
# To enable PSCache, you must configure it to be greater than 0. When it is greater than 0, poolPreparedStatements automatically triggers a change to true.
spring.datasource.druid.max-pool-prepared-statement-per-connection-size=50

#Tuning related: basically any project performance bottleneck 1.io 2.cpu computing volume
# configure monitoring statistics intercepted filters, after removing the monitoring interface sql can not be counted
spring.datasource.druid.filters=stat,wall

# connectProperties property to open mergeSql function; slow SQL record Slow query: add delete change check
spring.datasource.druid.connection-properties=druid.stat.mergeSql=true;
spring.datasource.druid.filter.stat.slow-sql-millis=1

# Merge monitoring data from multiple DruidDataSource
spring.datasource.druid.use-global-data-source-stat=true
# druid connection pool monitoring
spring.datasource.druid.stat-view-servlet.login-username=admin
spring.datasource.druid.stat-view-servlet.login-password=123
# exclude some static resources for efficiency
spring.datasource.druid.web-stat-filter.exclusions=*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*

Read More: