My Goal : Prevent batch Job from lunching while project startup.
I want to run a batch job from spring boot project once in every one hour using @scheduled annotation. However the job is starting as soon as I run the project....
spring.batch.job.enabled=false
@Scheduled( cron = "* * */1 * * *")
public void jobScheduled(){
logger.info("Job triggered");
getAllFileNames().stream().forEach( fileName-> {
jobRunner.runFlatFileBatchJob(fileName);
});
}
I have declared my class like below
@Configuration
@EnableScheduling
public class JobScheduler {
@Autowired
public JobScheduler(JobRunner jobRunner){
logger.info("job scheduler created... ");
this.jobRunner = jobRunner;
}
The Job is starting as soon as Run the application. I want it to wait till the project loads completely and other integration objects prepare themselves.
Thanks in advance.
Santrupta Dash