标签:let htm max cat pen tween 白名单 class min
一.添加依赖
<dependency> <groupId>com.alibaba</groupId> <artifactId>druid</artifactId> <version>1.1.6</version>
</dependency>
使用下面这个 上面那个会使SQL监控没数据。。 我也不知道why..
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.1.6</version>
</dependency>
二.修改application.properties中Druid的配置
druid: filters: stat max-active: 20 initial-size: 1 max-wait: 30000 min-idle: 1 time-between-eviction-runs-millis: 60000 min-evictable-idle-time-millis: 300000 test-while-idle: true test-on-borrow: false test-on-return: false pool-prepared-statements: false max-open-prepared-statements: -1 remove-abandoned: true remove-abandoned-timeout: 180 web-stat-filter-exclusions: ‘*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/*,/download/*,/wj/*,/assets/*‘
三.编写文件
DruidStatViewServlet.java
@SuppressWarnings("serial") @WebServlet(urlPatterns = "/druid/*", initParams={ //@WebInitParam(name="allow",value="10.238.100.189,127.0.0.1"),// IP白名单 (没有配置或者为空,则允许所有访问) @WebInitParam(name="allow",value="127.0.0.1"),// IP白名单 (没有配置或者为空,则允许所有访问) @WebInitParam(name="deny",value="192.168.16.111"),// IP黑名单 (存在共同时,deny优先于allow) @WebInitParam(name="loginUsername",value="druid"),// 用户名 @WebInitParam(name="loginPassword",value="druid"),// 密码 @WebInitParam(name="resetEnable",value="false")// 禁用HTML页面上的“Reset All”功能 }) public class DruidStatViewServlet extends StatViewServlet { }
DruidStatFilter
@WebFilter(filterName="druidWebStatFilter",urlPatterns="/*", initParams={ @WebInitParam(name="exclusions",value="*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/*")// 忽略资源 }) public class DruidStatFilter extends WebStatFilter { }
四.在程序入口增加注解 @ServletComponentScan 用来扫描Servlet类
标签:let htm max cat pen tween 白名单 class min
原文地址:https://www.cnblogs.com/bockpecehhe/p/9245111.html