spring Batch process is running automatically even with the spring.batch.job.enabled=false flag

544 Views Asked by At

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

0

There are 0 best solutions below