赞
踩
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.1.17</version>
</dependency>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Finchley.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.3.RELEASE</version>
<relativePath />
</parent>
spring: application: name: business-xxx-service-charles servlet: # 文件上传 文件大小限制 multipart: # Whether to enable support of multipart uploads. enabled: true # Max file size. Values can use the suffixes "MB" or "KB" to indicate megabytes or kilobytes, respectively. 默认1M maxFileSize: 5MB # Max request size. Values can use the suffixes "MB" or "KB" to indicate megabytes or kilobytes, respectively. 默认5M maxRequestSize: 30MB datasource: # 连接池配置 druid: url: jdbc:mysql://192.168.1.1:3306/xl_xxx username: root password: 123456 initialSize: 1 min-idle: 1 max-active: 20 # 申请连接时执行validationQuery检测连接是否有效,做了这个配置会降低性能。 test-on-borrow: true driver-class-name: com.mysql.jdbc.Driver # druid 监控配置 访问路径:http://localhost:6211/vipDruid/login.html filter: stat: # 用于统计监控信息。 enabled: true # 启用 slow-sql-millis: 1000 # 记录超过此指定时间的 慢sql 单位:ms merge-sql: true # 合并相同sql的统计 wall: enabled: true # 启用sql检测功能 ,防止sql注入攻击,sql防火墙启用 slf4j: enabled: true # 开启日志管理,监控页面可重置记录 web-stat-filter: # web应用 监控配置 enabled: true profile-enable: true # 能够监控单个url调用的sql列表 url-pattern: /* # 监控路径控制 eg: /admin/* exclusions: '*.js,*.gif,*.jpg,*.png,*.css,*.ico,/vipDruid/*' # 不拦截的路径 stat-view-servlet: # druid 监控页面入口控制 enabled: true allow: 127.0.0.1,192.168.1.1/27 # ip白名单 只有当前名单中的ip才能访问 1/27表示ip前27位相同即可 deny: 192.168.1.255 # ip黑名单,禁止访问的地址 优先级高于白名单 login-username: druid # druid 监控页面登录账号 login-password: 123654 # druid 监控页面登录密码 url-pattern: /vipDruid/* # 监控页面访问路径配置 reset-enable: true # 是否能够重置数据 useGlobalDataSourceStat: true # 合并多个DruidDataSource的监控数据 # 过滤器配置 可配置多个 ,使用逗号分隔 stat,wall; 不指定过滤器的参数使用默认,也可单独制定过滤器 # 此方法与上面的 filter 单独配置开启是一样的,只不过上面可以使用个性化配置,而filters使用默认配置,所以这两个配置可以不同时使用 # filters: stat,wall aop-patterns: com.xlcloud.business.vip.service.* # Spring 监控路径
由于上面已经已经对很对配置进行了解释说明,下面就不在赘述,截图说明效果。
访问地址:http://localhost:6211/vipDruid/login.html
注意:端口(6211)是项目的访问的端口
由前面的配置是service层监控,所以会监控所有service层方法的调用情况
Druid 配置参考文档
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。