springBoot最新版本2.3.0 JDBC及Druid數據源配置文件

spring:
  datasource:
      url: jdbc:mysql://192.168.43.124/jdbc
      driver-class-name: com.mysql.cj.jdbc.Driver
      username: root
      password: 123456
      platform: mysql
      initialization-mode: always
      data-username: root
      data-password: 123456
      schema-username: root
      schema-password: 123456
      type: com.alibaba.druid.pool.DruidDataSource
      schema:
        - classpath:department.sql

# 初始化大小,最小,最大
      initialSize: 1
      minIdle: 3
      maxActive: 20
      # 配置獲取連接等待超時的時間
      maxWait: 60000
      # 配置間隔多久才進行一次檢測,檢測需要關閉的空閒連接,單位是毫秒
      timeBetweenEvictionRunsMillis: 60000
      # 配置一個連接在池中最小生存的時間,單位是毫秒
      minEvictableIdleTimeMillis: 30000
      validationQuery: select 'x'
      testWhileIdle: true
      testOnBorrow: false
      testOnReturn: false
      # 打開PSCache,並且指定每個連接上PSCache的大小
      poolPreparedStatements: true
      maxPoolPreparedStatementPerConnectionSize: 20
      # 配置監控統計攔截的filters,去掉後監控界面sql無法統計,'wall'用於防火牆
      filters: stat,wall,slf4j
      # 通過connectProperties屬性來打開mergeSql功能;慢SQL記錄
      connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
      # 合併多個DruidDataSource的監控數據
      useGlobalDataSourceStat: true

僅供參考,高手請忽略本帖!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章