1

I am using Spring Boot with Spring Data JPA to query database through Repository. If the backend database is booted for some reason, then Spring Boot cannot connect to that database again unless rebooted. Is there a way to get the Data JPA to repopulate connections to database after DB reboot?

user1340582
  • 19,151
  • 35
  • 115
  • 171

1 Answers1

2

In Spring Boot, we can solve this problem adding these configurations in the application.properties file:

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

Checkout the full explanation here

inafalcao
  • 1,415
  • 1
  • 11
  • 25