嚴重: testWhileIdle is true, validationQuery not set 使用Druid連接池報錯處理


環境:  JDK8  、MYSQL 5.7.17 、Spring boot 2.1.6  、Druid - 1.1.10 的jar包;

使用 druid-1.1.10.jar 報錯如下;

3月 25, 2020 7:55:37 下午 com.alibaba.druid.pool.DruidDataSource error
嚴重: testWhileIdle is true, validationQuery not set
3月 25, 2020 7:55:50 下午 com.alibaba.druid.pool.DruidDataSource info
信息: {dataSource-1} inited

在properties配置文件下添加一些配置;

filters=stat
initialSize=2
maxActive=300
maxWait=60000
timeBetweenEvictionRunsMillis=60000
minEvictableIdleTimeMillis=300000
validationQuery=SELECT 1
testWhileIdle=true
testOnBorrow=true
testOnReturn=false
poolPreparedStatements=false
maxPoolPreparedStatementPerConnectionSize=200

完整配置如下:

spring:
  application:
    name: test
  datasource:
    url: jdbc:mariadb://127.0.0.1:3306/test?characterEncoding=utf-8
    driver-class-name: org.mariadb.jdbc.Driver
    type: com.alibaba.druid.pool.DruidDataSource
    druid:
      initial-size: 15
      min-idle: 15
      max-active: 200
      max-wait: 60000
      time-between-eviction-runs-millis: 60000
      min-evictable-idle-time-millis: 300000
      validation-query: select 1
      test-while-idle: true
      test-on-borrow: true
      test-on-return: false
      pool-prepared-statements: false
      connection-properties: false
      filters: stat,slf4j
      filter:
        slf4j:
          connection-log-enabled: false
          data-source-log-enabled: false
          result-set-log-enabled: false
          statement-log-enabled: true
      web-stat-filter:
        enabled: false
      log-abandoned: true
      remove-abandoned: true
      remove-abandoned-timeout: 60
      keep-alive: true
      max-pool-prepared-statement-per-connection-size: 10

再次運行;

3月 25, 2020 8:14:13 下午 com.alibaba.druid.pool.DruidDataSource info
信息: {dataSource-1} inited

報錯2;

信息: {dataSource-1} inited

這是日志信息,沒有錯Druid采用了日志打印機制,這不是報錯;

連接池采用了懶加載,真正用到的時候才初始化;

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM