原始配置:
type: com.alibaba.druid.pool.DruidDataSource druid:initial-size: 5max-active: 25min-idle: 5max-wait: 10000testWhileIdle: truetestOnBorrow: falsetestOnReturn: falsetimeBetweenEvictionRunsMillis: 2000minEvictableIdleTimeMillis: 600000maxEvictableIdleTimeMillis: 900000validationQuery: SELECT 1 FROM DUAL
修改后配置:增加keep-alive: true即可
type: com.alibaba.druid.pool.DruidDataSource druid:initial-size: 5max-active: 25min-idle: 5max-wait: 10000testWhileIdle: truetestOnBorrow: falsetestOnReturn: falsetimeBetweenEvictionRunsMillis: 2000minEvictableIdleTimeMillis: 600000maxEvictableIdleTimeMillis: 900000validationQuery: SELECT 1 FROM DUALkeep-alive: true
需要升级Druid版本到1.1.16之后,大于1.1.16版本,我升级到了1.1.17
https://mvnrepository.com/artifact/com.alibaba/druid-spring-boot-starter
<dependency><groupId>com.alibaba</groupId><artifactId>druid-spring-boot-starter</artifactId><version>1.1.17</version> </dependency>
keep-alive配置建议参考:https://github.com/alibaba/druid/wiki/DruidDataSource%E9%85%8D%E7%BD%AE