My application is based on spring boot. I want to create a task which should be run only once after application has been started.
Currently, I am looking into two solutions:
Using @Scheduled
and boolean property which should determine whether the logic shold be run or not.
@Scheduled
public void method(){
if(method_run_propery){
//do something;
}
}
Using Quartz. But I have not used before.
Please, tell me what is the best approach to use in this case.
Spring has a @PostConstruct annotation to do exactly that. Runs once the bean has been initialized and all dependencies added.