【问题标题】:How to start spring batch job on rest call from UI with parameters如何从带有参数的 UI 调用休息时启动 Spring 批处理作业
【发布时间】:2019-07-27 21:12:05
【问题描述】:

我是春季批次的新手。我想在按钮单击时开始春季批处理作业。我正在将 UI 中的 jobDTO 和 id 传递给 Java 控制器。我的基于 jobDTO 和 id 的 Java 控制器对启动作业进行了进一步处理。我必须对 Spring Batch 做同样的事情,我该如何做到这一点? 下面是我的 java 控制器代码。

@RequestMapping(method = RequestMethod.POST)
public Response<JobDTO> createJobInstance(@RequestBody JobDTO jobDTO,
        @PathVariable("Id") long id) throws Exception {
    return execService.createNewJobInstance(context, id, jobeDTO);
}

【问题讨论】:

    标签: java html angularjs spring-boot


    【解决方案1】:

    可以关注spring批处理文档here

    @Controller
    public class JobLauncherController {
    
      @Autowired
      JobLauncher jobLauncher;
    
      @Autowired
      Job job;
    
      @RequestMapping("/jobLauncher.html")
      public void handle() throws Exception{
         jobLauncher.run(job, new JobParameters());
      }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-01
      • 2023-04-08
      • 1970-01-01
      • 1970-01-01
      • 2019-11-14
      • 1970-01-01
      相关资源
      最近更新 更多