title: How to trigger a scheduled Spring Batch Job?
body: <p>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.</p>
  
  <p>So this is my Controller:</p>
  
  <pre><code>@RestController
  public class LauncherController {
  
      @Autowired
      JobLauncher jobLauncher;
  
      @Autowired
      Job job;
  
      @RequestMapping("/launch")
      public String launch() throws Exception {
               ...
              jobLauncher.run(job, jobParameters);
      }
  </code></pre>
  
  <p>This is some part of the Batch conf:</p>
  
  <pre><code>@Configuration
  @EnableBatchProcessing
  @EnableScheduling
  public class BatchConfiguration {
  
      @Autowired
      public JobBuilderFactory jobBuilderFactory;
  
      @Autowired
      public StepBuilderFactory stepBuilderFactory;
  
      @Scheduled(cron = "0/5 * * * * ?")
      @Bean
      public Job job() {
          return jobBuilderFactory.get("job")
                  .incrementer(new RunIdIncrementer())
                  .flow(step1())
                  .end()
                  .build();
      }
  
      @Bean
      public Step step1() {
          return stepBuilderFactory.get("step1")
                  .&lt;Person, Person&gt; chunk(10)
                  .reader(reader())
                  .processor(processor())
                  .writer(writer())
                  .build();
      }
  </code></pre>
  
  <p>I have also set the property spring.batch.job.enabled=false, since i do not want the jobs run as soon as the Spring Boot App starts.</p>
  
  <p>Now i can call my Rest api lauch, and the job runs, but only once. Scheduler does not work. And I could not figure it our where exactly i should define my @Scheduled Annotation.. </p>