在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配置類,請註解即可