记录一次配置druid yaml中sql监控与防火墙失效
1,正常引入druid-starter后yaml中配置
sql监控与防火墙是以下方式
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| spring: datasource: url: jdbc:mysql://localhost:3306/test username: root password: 123123 driver-class-name: com.mysql.cj.jdbc.Driver
druid: aop-patterns: com.ren.admin.* filters: wall,stat
stat-view-servlet: enabled: true login-username: 123 login-password: 123123 reset-enable: false
web-stat-filter: enabled: true url-pattern: /* exclusions: '*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*' filter: stat: log-slow-sql: true slow-sql-millis: 1 enabled: true wall: enabled: true config: drop-table-allow: false
|
2,启动后执行sql防火墙与sql监控页均为空白
3,检查数据源后发现filter类名为空的现象
4,解决方案
将yaml配置文件中filters移到datasource下
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| spring: datasource: url: jdbc:mysql://localhost:3306/test username: root password: 123123 driver-class-name: com.mysql.cj.jdbc.Driver
filters: wall,stat filter: stat: log-slow-sql: true slow-sql-millis: 1 enabled: true wall: enabled: true config: drop-table-allow: false
druid: aop-patterns: com.ren.admin.*
stat-view-servlet: enabled: true login-username: 123 login-password: 123123 reset-enable: false
web-stat-filter: enabled: true url-pattern: /* exclusions: '*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*'
|
5,成功解决问题