Spring Batch - A job instance already exists: JobInstanceAlreadyCompleteException

With your current setup you will only be able to launch the job only once.

    launcher.run(job, new JobParameters());

The job is unique identified by its id together with the parameters. Currently there is no way to make a distinction based on the parameters. Instead of adding new JobParameters() use the JobParamtersBuilderBuilder and add the current date and time.

JobParametersBuilder builder = new JobParametersBuilder();
builder.addDate("date", new Date());
launcher.run(job, builder.toJobParameters());

This will allow you to run the job multiple times.


add the line to jobBuilderFactory chain

.incrementer(new RunIdIncrementer())

next (as you run job manually with jobLauncher and with custom JobParameters)

paramsBuilder.getNextJobParameters(job);

instead of .addDate("date", new Date()); like they advicing you