title: repeat job in spring batch (and stop, start)
body: <p>I wanna perform repetitive tasks using Spring batch.</p>
  
  <p>For example, stop and restart a job that outputs the minimum value in the database table using the controller.</p>
  
  <p>(never mind the logic that the step executes)</p>
  
  <p>or is it impossible using spring batch..?? then let me know another way (like @Scheduled)</p>
  
  <pre><code>@Configuration
  public class someJob{
  
      private final JobBuilderFactory jobBuilderFactory;
      private final StepBuilderFactory stepBuilderFactory;
  
  // make it repeat infinitely
      @Bean
      public Job job() {
          return jobBuilderFactory.get("job").start(step()).build();
      }
  
      @Bean
      public Step step() {
          return stepBuilderFactory.get("step").tasklet(some_task).build();
      }
  }
  
  -----------------------------------------------------
  @RestController
  @RequestMapping("/control")
  public class Controller {
  
  
      @PostMapping("/restart")
      public void restart() {
          // restart job
      }
  
      @PostMapping("/stop/{jobId}")
      public void stop() {
          // stop job
      }
  }
  
  </code></pre>