I want to be able to start my job with a REST controller, then when the job is started, it should run on a scheduled basis, until i stop it again with REST.
So this is m
@Scheduled
is defined on a method and not on a Bean. So create a new Class which will be a Bean
public class BatchConfiguration {
...
@Bean
public Job job() {
return new Job();
}
new Class:
public class Job {
@Scheduled(cron = "0/5 * * * * ?")
public Job job() {
return jobBuilderFactory.get("job")
.incrementer(new RunIdIncrementer())
.flow(step1())
.end()
.build();
}