[Posts] springboot2.0 connection pool configuration (hikari, druid) springboot2.0 connection pool configuration (hikari, druid)

springboot2.0 connection pool configuration (hikari, druid)

Original link: https://www.cnblogs.com/blog5277/p/10660689.html

Original author: blog Garden - Qu high end and oligo

******************* If you see this line, indicating reptiles in my not yet released complete when he captured my article, leading to incomplete, please to the above description link to view the original ****************

 

After springboot2.0, comes with a connection pool called the world's fastest hikari, the following configuration can be entered directly in the configuration file:

Copy the code
# Hikari will use the above plus the following to setup connection pooling
spring.datasource.type=com.zaxxer.hikari.HikariDataSource
spring.datasource.hikari.minimum-idle=5
spring.datasource.hikari.maximum-pool-size=15
spring.datasource.hikari.auto-commit=true
spring.datasource.hikari.idle-timeout=30000
spring.datasource.hikari.pool-name=HikariCP
spring.datasource.hikari.max-lifetime=1800000
spring.datasource.hikari.connection-timeout=30000
spring.datasource.hikari.connection-test-query=SELECT 1
Copy the code

But then, I do not just want to connect the pool, I also want to monitor a page, there are so many Ali monitoring content, I really feel very practical, direct point of view slow ah log in page, session statistics, ah, I still Quite like

After the last druid want to configure the monitor page, you need to write a bunch of files and configuration, quite troublesome, for springboot Ali made a druid-starter, monitoring becomes easy one, first joined the pom file:

Copy the code
<!-- https://mvnrepository.com/artifact/com.alibaba/druid-spring-boot-starter -->
<dependency>
    <groupId>com.alibaba</groupId>
    <artifactId>druid-spring-boot-starter</artifactId>
    <version>1.1.14</version>
</dependency>
Copy the code

Then in the configuration file directly added to the configuration:

Copy the code
spring.datasource.druid.initial-size=5
spring.datasource.druid.min-idle=5
spring.datasource.druid.maxActive=20
spring.datasource.druid.maxWait=60000
spring.datasource.druid.timeBetweenEvictionRunsMillis=60000
spring.datasource.druid.minEvictableIdleTimeMillis=300000
spring.datasource.druid.validationQuery=SELECT 1 
spring.datasource.druid.testWhileIdle=true
spring.datasource.druid.testOnBorrow=false
spring.datasource.druid.testOnReturn=false
spring.datasource.druid.poolPreparedStatements=true
spring.datasource.druid.maxPoolPreparedStatementPerConnectionSize=20
spring.datasource.druid.filters=stat,wall
= druid.stat.mergeSql spring.datasource.druid.connectionProperties \ = to true; druid.stat.slowSqlMillis \ = 5000 
spring.datasource.druid.web to true-STAT-filter.enabled = 
spring.datasource.druid.web-STAT- =-pattern filter.url / * 
spring.datasource.druid.web-STAT-filter.exclusions = *. JS, *. GIF, *. JPG, *. BMP, *. PNG, *. CSS, *. ICO, / Druid / * 
spring.datasource.druid.stat-View-servlet.deny = 192.168.1.73 
spring.datasource.druid.stat-View-servlet.reset-enable = false 
# 4 or less, after the production environment in the future must be change! ! ! ! ! Must be changed! ! ! ! ! Must be changed! ! ! ! ! 
-View-servlet.url-spring.datasource.druid.stat pattern = / Druid / * 
spring.datasource.druid.stat-View-servlet.allow = 127.0.0.1, * 
spring.datasource.druid.stat-View-the servlet .login-username = admin 
spring.datasource.druid.stat-View-the servlet .login-password = 123456
Copy the code

Then re-start the project on it, super simple, go to localhost: ip / druid can look at the monitor, point the figure head of the table can be sorted Oh, slow query analysis because what is very convenient

Guess you like

Origin www.cnblogs.com/jinanxiaolaohu/p/12020272.html