How to stop application deployment till db is up

33 Views Asked by At

In springboot, I have a cron expression which is taken from db. The problem is the db is deployed with application and cron expression is given as a seed data but when the application starts the scheduler is called before db is created and I get a null pointer. I tried using @PostConstruct but it dint work out. Any suggestions?

1

There are 1 best solutions below

2
Timothy Njonjo On

Your question is not clear. But if the error occurs on @PostConstruct, then you can do an eventListener to listen when the application is ready

@EventListener(ApplicationReadyEvent.class)
public void onApplicationReady(){
 // Do your stuff
}