配置druid连接池监控
Posted bluss-yang
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了配置druid连接池监控相关的知识,希望对你有一定的参考价值。
用
<dependency> <groupId>com.alibaba</groupId> <artifactId>druid</artifactId> <version>1.0.31</version> </dependency>
这个依赖我的sql监控没出来,没办法我去官网看了下,用springboot启动器这个竟然可以正常显示,也可能是我的config文件写的有问题,有时间我再试试
https://github.com/alibaba/druid/tree/1.1.14/druid-spring-boot-starter/src/test
我把这单个文件整合到一个文件里。
<dependency> <groupId>com.github.pagehelper</groupId> <artifactId>pagehelper-spring-boot-starter</artifactId> <version>1.2.10</version> </dependency>
# JDBC配置 spring.datasource.url= spring.datasource.username= spring.datasource.password= spring.datasource.driver-class-name=oracle.jdbc.driver.OracleDriver spring.datasource.type=com.alibaba.druid.pool.DruidDataSource #filter spring.datasource.druid.filter.stat.enabled=true spring.datasource.druid.filter.config.enabled=true spring.datasource.druid.filter.encoding.enabled=true #spring.datasource.druid.filter.wall.enabled=true #isue 1796 spring.datasource.druid.max-evictable-idle-time-millis=200000 # Druid 数据源配置,继承spring.datasource.* 配置,相同则覆盖 spring.datasource.druid.initial-size=2 spring.datasource.druid.max-active=30 spring.datasource.druid.min-idle=2 spring.datasource.druid.max-wait=1234 spring.datasource.druid.pool-prepared-statements=true spring.datasource.druid.max-pool-prepared-statement-per-connection-size=5 # spring.datasource.druid.max-open-prepared-statements= #等价于上面的max-pool-prepared-statement-per-connection-size spring.datasource.druid.validation-query=select 1 from dual spring.datasource.druid.validation-query-timeout=1 spring.datasource.druid.test-on-borrow=true spring.datasource.druid.test-on-return=true spring.datasource.druid.test-while-idle=true spring.datasource.druid.time-between-eviction-runs-millis=10000 spring.datasource.druid.min-evictable-idle-time-millis=30001 spring.datasource.druid.async-close-connection-enable=true spring.datasource.druid.aop-patterns=com.yzl.service.* # 自定义StatFilter 配置 其他 Filter 不再演示 spring.datasource.druid.filter.stat.db-type=oracle spring.datasource.druid.filter.stat.log-slow-sql=true spring.datasource.druid.filter.stat.slow-sql-millis=2000 # JPA spring.jpa.show-sql= true spring.jpa.hibernate.ddl-auto=create-drop # 配置下面参数用于启动监控页面,考虑安全问题,默认是关闭的,按需开启 spring.datasource.druid.stat-view-servlet.enabled=true spring.datasource.druid.web-stat-filter.enabled=true # 更多配置属性见 DruidDataSource 内成员变量(只要有set方法便支持),或者根据IDE提示,或者查看官方文档 #下面配置说明请参考Druid Github Wiki,配置_配置WebStatFilter #是否启用StatFilter默认值true spring.datasource.druid.web-stat-filter.url-pattern=/* spring.datasource.druid.web-stat-filter.exclusions=*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid2/* spring.datasource.druid.web-stat-filter.session-stat-enable=true spring.datasource.druid.web-stat-filter.session-stat-max-count=12 spring.datasource.druid.web-stat-filter.principal-session-name= spring.datasource.druid.web-stat-filter.principal-cookie-name= spring.datasource.druid.web-stat-filter.profile-enable=true #下面配置说明请参考Druid Github Wiki,配置_StatViewServlet配置 #是否启用StatViewServlet默认值true spring.datasource.druid.stat-view-servlet.url-pattern=/druid/* spring.datasource.druid.stat-view-servlet.reset-enable=true spring.datasource.druid.stat-view-servlet.login-username= spring.datasource.druid.stat-view-servlet.login-password= spring.datasource.druid.stat-view-servlet.allow= spring.datasource.druid.stat-view-servlet.deny= #下面配置说明请参考Druid Github Wiki,配置_Druid和Spring关联监控配置 #如果spring.datasource.druid.aop-patterns要代理的类没有定义interface请设置spring.aop.proxy-target-class=true
以上是关于配置druid连接池监控的主要内容,如果未能解决你的问题,请参考以下文章