在springboot 2.x 直接在yml配置类中配置
filters: stat,wall #说明: stat用于监控--wall用于防火墙
#启用sql监控
druid:
stat-view-servlet:
url-pattern: /druid/* #web访问路径
allow: localhost #允许访问的ip,不配置默认所有地址都可以访问
login-username: admin #访问需要的用户名
login-password: admin #访问需要的密码
enabled: true #启用
#启用web-uri+session监控
druid:
web-stat-filter:
url-pattern: /* #过滤url
exclusions: /druid/* #排除过滤 "*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/*"
enabled: true #启用
profile-enable: true #监控单个url调用的sql列表
若有配置context-path:mypath
访问时localhost:server-port/mypath/druid/即可
没有配置context-path
访问时localhost:server-port/druid/即可
若发现登陆时密码验证错误之类的,请检查是否有自己写过DruidConfig配置类,默认springboot2.x只需要在yml/properties中配置好即可,若自己有注入druid配置类,请注解即可