导读 | Druid阿里巴巴开源的一个java数据库连接池,是Java语言中最好的数据库连接池,Druid能够提供强大的监控和扩展功能;集成它能够方便我们对数据库连接进行监控和分析,下面我们来集成它。 |
1、 集成druid
1-1、添加依赖
<dependency> <groupid>com.alibaba</groupid> <artifactid>druid-spring-boot-starter</artifactid> <version>1.1.10</version> </dependency>
1-2、添加配置
#druid 配置 spring.application.name=springboot-test-exam1 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 FROM DUAL 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,slf4j spring.datasource.druid.connectionProperties=druid.stat.mergeSql/=true;druid.stat.slowSqlMillis/=5000 spring.datasource.druid.web-stat-filter.enabled=true spring.datasource.druid.web-stat-filter.url-pattern=/* spring.datasource.druid.web-stat-filter.exclusions=*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/* spring.datasource.druid.stat-view-servlet.url-pattern=/druid/* #spring.datasource.druid.stat-view-servlet.allow=127.0.0.1,192.168.163.1 #spring.datasource.druid.stat-view-servlet.deny=192.168.1.73 spring.datasource.druid.stat-view-servlet.reset-enable=false spring.datasource.druid.stat-view-servlet.login-username=admin spring.datasource.druid.stat-view-servlet.login-password=123456
1-3、运行
好了,这样就集成了,可以直接运行了,端口/druid就能看到了:
用自己在配置文件中设置的用户名和密码登录:
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/tech/linux/125548.html