Druid推荐配置

Durid 和SpringBoot整合配置

## spring配置
spring:
  datasource:
    druid:
      driver-class-name: com.mysql.cj.jdbc.Driver
      type: com.alibaba.druid.pool.DruidDataSource
      url: jdbc:mysql://127.0.0.1:10086/db_druid?characterEncoding=UTF-8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&useUnicode=true&serverTimezone=Hongkong
      username: dly
      password: mima
      # 以下是druid的配置
      # 最大存活
      max-active: 20
      # 初始化连接个数
      initial-size: 1
      # 最小连接个数
      min-idle: 1
      # 最大等待时间
      max-wait: 10000
      # 间隔多久检测需要关闭空闲连接
      time-between-eviction-runs-millis: 60000
      # 连接在池中最小生存是时间
      min-evictable-idle-time-millis: 300000
      # 检测空闲连接是否有效
      keep-alive: true
      # 测试sql
      validation-query: select 1
      validation-query-timeout: 3
      async-init: true
      # 监控配置
      filters: stat,slf4j,wall
      filter:
        stat:
          enabled: true
          db-type: mysql
          log-slow-sql: true
          # 执行超过5S就会打印SQL
          slow-sql-millis: 5000
        slf4j:
          enabled: true
          connection-log-enabled: true
          statement-sql-pretty-format: true
        wall:
          enabled: true
          log-violation: true
          config:
            # 检查是否无where条件
            delete-where-none-check: true
            update-where-none-check: true
            truncate-allow: false
            alter-table-allow: false
            drop-table-allow: false
      web-stat-filter:
        enabled: true
        url-pattern: /*
        exclusions: '*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*'
        session-stat-enable: false
      stat-view-servlet:
        enabled: true
        url-pattern: /druid/*
        reset-enable: false
        login-username: druid
        login-password: 123456

你可能感兴趣的:(Druid推荐配置)