druid yml 中 comment-allow 配置不起作用

6ovsh4lw  于 2022-11-02  发布在  Druid
关注(0)|答案(6)|浏览(312)
datasource:
  druid:
      filter:
        wall:
          config:
            comment-allow: true

这边打了断点并没有走进来

sql 执行时 config.isCommentAllow() = false

这是druid相关所有配置

datasource:
    druid:
      type: com.alibaba.druid.pool.DruidDataSource
      driver-class-name: com.mysql.cj.jdbc.Driver

# driver-class-name: com.p6spy.engine.spy.P6SpyDriver

      url: jdbc:mysql://****:**/**?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8
      username:**
      password:**
      initial-size: 5
      min-idle: 5
      max-active: 20
      max-wait: 30000
      time-between-eviction-runs-millis: 60000
      min-evictable-idle-time-millis: 300000
      validation-query: select '1' from dual
      test-while-idle: true
      test-on-borrow: false
      test-on-return: false
      pool-prepared-statements: true
      max-open-prepared-statements: 20
      max-pool-prepared-statement-per-connection-size: 20
      filters: stat,slf4j,wall

      web-stat-filter:
        enabled: true
        url-pattern: /*
        exclusions: '*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*'

      stat-view-servlet:
        enabled: true
        url-pattern: /druid/*
        reset-enable: false
        login-username:**
        login-password:**

      filter:
        stat:
          enabled: true
          log-slow-sql: true
          slow-sql-millis: 1000
          db-type: mysql
          merge-sql: true
        slf4j:
          enabled: true
          statement-create-after-log-enabled: false
          statement-log-enabled: false
          statement-executable-sql-log-enable: true
          statement-log-error-enabled: true
          result-set-log-enabled: true
        wall:
          config:
            comment-allow: true
gudnpqoy

gudnpqoy2#

这样配置

datasource:
  druid:
      filter:
        wall:
          config:
            enabled: true
            comment-allow: true
q9rjltbz

q9rjltbz3#

我遇到类似问题,尝试后发现移除 spring.datasource.druid.filters=stat,wall,log4j
使用以下方式分开配置

spring.datasource.druid.filter.stat.enabled=true
spring.datasource.druid.filter.log4j.enabled=true
spring.datasource.druid.filter.wall.enabled=true
spring.datasource.druid.filter.wall.config.comment-allow=true

就可以了

z0qdvdin

z0qdvdin4#

我遇到类似问题,尝试后发现移除 spring.datasource.druid.filters=stat,wall,log4j
使用以下方式分开配置

spring.datasource.druid.filter.stat.enabled=true
spring.datasource.druid.filter.log4j.enabled=true
spring.datasource.druid.filter.wall.enabled=true
spring.datasource.druid.filter.wall.config.comment-allow=true

就可以了

there is no need to remove spring.datasource.druid.filters=stat,wall,log4j .

spring.datasource.druid.filter.wall.enabled=true is already enough to make wall.config.comment-allow work.

0lvr5msh

0lvr5msh5#

后来解决了吗,怎么解决的,可以分享下吗

2skhul33

2skhul336#

后来解决了吗,怎么解决的,可以分享下吗

版本: 1.1.21
yml 配置成这样,就可以:

datasource:
druid:
filter:
wall:
enabled: true
config:
comment-allow: true

相关问题