druid use and configuration

First, add a dependency: 

<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.1.9</version>
</dependency>

Then configure application.yml 

  

type: com.alibaba.druid.pool.DruidDataSource 

configuration connection pool #
# initial size, minimum, maximum
initialSize:. 3
minIdle:. 5
for maxActive: 20 is

# configuration obtaining connection waiting timeout time
maxWait: 30000
# intervals the frequency of such a detector detecting the connection needs to close idle milliseconds
timeBetweenEvictionRunsMillis: 60000

# configure a minimum connection time survival pool milliseconds
minEvictableIdleTimeMillis: 300000
validationQuery: the SELECT the FROM. 1 the DUAL
testWhileIdle: to true
testOnBorrow: to false
testOnReturn: to false

# open PSCache, and specifies the size of each connection PSCache
poolPreparedStatements: to true
maxPoolPreparedStatementPerConnectionSize: 20 is
# configure the monitoring statistics intercepted filters, after removing the monitoring interface can not sql statistics, 'wall' firewalls
Filters: STAT, Wall
# properties by connectProperties open mergeSql functions; slow SQL record
connectionProperties.druid.stat.mergeSql.true;druid.stat.slowSqlMillis: 10000

 

/ ** 
* Druid's representative statistics.
* Html page provides monitoring information display
* provide monitoring information API JSON
*
* /
the @WebServlet (
        urlPatterns = { "/ druid / * "}, // monitor page access path 
the initParams = {
@WebInitParam (name = "loginUsername", value = "ADMIN"), // Login
@WebInitParam (name = "loginPassword", value = "qwert"), // password
@WebInitParam (name = "resetEnable", value = "false") // reset button monitoring-page (when set to false monitoring page reset button does not work)
}
)
public class DruidStatViewServlet the extends StatViewServlet {
}



 

Guess you like

Origin www.cnblogs.com/rempop/p/11084160.html