Home > database >  how do I get spring boot to retry when getting mysql dataSource?
how do I get spring boot to retry when getting mysql dataSource?

Time:05-08

so I have a spring boot application inside docker compose, and it relies on a mysql container, the problem is it tries to open a connection before the mysql container is ready, and it crashes.

I found that I can use

spring.datasource.hikari.initializationFailTimeout=0

in my application.properties, but only seems to make it wait for a couple of seconds longer before crashing, any ideas ?

CodePudding user response:

Kindly add this to your docker compose in your container config restart: unless-stopped

google: 'Unless-stopped' restarts the container only when any user executes a command to stop the container, not when it fails because of an error. 'Always' restarts the container whether the it's caused by an error, or is executed by a user, or if Docker is restarted

  • Related