title: How to select which job should run in Spring Batch + Spring Rest API
body: <p>I'm trying to implement to 2 Spring Batch jobs which will run when an endpoint is consumed.  Since JobLauncher method is the same for both of them, how can you select which one is going to be executed?</p>
  
  <pre><code>@Autowired
  private JobLauncher jobLauncher;
  
  @Autowired
  private Job job;
  
  @RequestMapping(
          value = "/expired",
          method = RequestMethod.GET,
          produces = MediaType.APPLICATION_JSON_UTF8_VALUE,
          params = {"expireDate"}
  )
  @ResponseBody
  public ResponseDTO expiredJob(@RequestParam(value = "expireDate") String expireDate) throws BusinessException, Exception {
  
      if (!DateValidator.isDateFormatValid(expireDate)) {
          throw new BusinessException(ExceptionCodes.DATE_FORMAT_ERROR);
      }
      JobParameters jobParameters = new JobParametersBuilder().addString("expireDate", expireDate).toJobParameters();
      jobLauncher.run(job, jobParameters);
  
      ResponseDTO responseDTO = new ResponseDTO();
  
      return responseDTO;
  }
  
  @RequestMapping(
          value = "/lucky",
          method = RequestMethod.GET,
          produces = MediaType.APPLICATION_JSON_UTF8_VALUE
  )
  @ResponseBody
  public ResponseDTO rciplusJob() throws BusinessException, Exception {
  
      JobParameters jobParameters = new JobParameters();
      jobLauncher.run(job, jobParameters);
  
      ResponseDTO responseDTO = new ResponseDTO();
  
      return responseDTO;
  }
  </code></pre>