任何人都可以告诉我如何在基于Web的Java应用程序中配置spring批处理。 我在互联网上看了很多,但没有任何基于网络的弹簧批处理的例子。 任何人都可以分享任何基于网络的弹簧批处理示例吗?
答案 0 :(得分:0)
使用JobOperator可以轻松完成弹簧批次的所有调用。实际上spring batch documentation中提供了大量信息。
private JobOperator jobOperator;
@RequestMapping(value = "/", method = RequestMethod.GET)
@ResponseStatus(HttpStatus.ACCEPTED)
public String launch() {
List<JobInstance> jobInstances = jobExplorer.getJobInstances("myJob", 0, 10);
List<String> all = jobInstances.stream()
.map(jobExplorer::getJobExecutions)
.flatMap(Collection::stream)
.map(JobExecution::toString)
.collect(Collectors.toList());
return all;
}
@RequestMapping(value = "/", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.ACCEPTED)
public Long restartJob(@RequestParam("execId") Long executionId) {
return jobOperator.restart(executionId);
}
@RequestMapping(value = "/", method = RequestMethod.PUT)
@ResponseStatus(HttpStatus.ACCEPTED)
public Long startJob() {
return jobOperator.start("jobName", "parameters...");
}