0

In old spring version we can do it using the code below into application.properties:

spring.datasource.testWhileIdle = true
spring.datasource.timeBetweenEvictionRunsMillis = 3600000
spring.datasource.validationQuery = SELECT 1

but now? How to do it in new spring boot 2.0.0.RELEASE ?

Michael Petch
  • 46,082
  • 8
  • 107
  • 198
jonas.lima
  • 116
  • 11

1 Answers1

0

add tomcat

spring.datasource.tomcat.testOnBorrow=true 
spring.datasource.tomcat.validationQuery=SELECT 1

Note that the use of autoReconnect is not recommended. '1.4+ defines specific namespaces for the four connections pools Spring Boot supports: tomcat, hikari, dbcp, dbcp2 (dbcp is deprecated as of 1.5).' more in: Spring Boot JPA - configuring auto reconnect

Rabbid76
  • 202,892
  • 27
  • 131
  • 174