我有spring批处理设置,并且试图并行运行两个作业。我的一项工作正常,但是添加第二项工作时它将停止工作。作业设置如下:
<job id="job">
<split id="split_1" task-executor="taskExecutor" next="step_4">
<flow>
<step id="step_1">
<tasklet ref="taskletStep_1"/>
</step>
</flow>
<flow>
<step id="step_2">
<tasklet ref="taskletStep_2"/>
</step>
</flow>
<flow>
<step id="step_3">
<tasklet ref="taskletStep_3"/>
</step>
</flow>
</split>
<step id="step_4">
<tasklet ref="taskletStep_3"/>
</step>
</job>
<job id="job2">
<split id="split_2" task-executor="taskExecutor" next="step_8">
<flow>
<step id="step_5">
<tasklet ref="taskletStep_4"/>
</step>
</flow>
<flow>
<step id="step_6">
<tasklet ref="taskletStep_5"/>
</step>
</flow>
<flow>
<step id="step_7">
<tasklet ref="taskletStep_6"/>
</step>
</flow>
</split>
<step id="step_8">
<tasklet ref="taskletStep_6"/>
</step>
</job>
与一项工作一起使用时效果很好。当我添加第二份工作时,第一份工作正常,但第二份工作呈现:
INFO 40904 --- [nio-8181-exec-1] c.j.b.p.c.JobLauncherController : The Job must not be null.
作业启动器设置如下:
@RestController
public class JobLauncherController {
@Autowired
JobLauncher jobLauncher;
@Autowired
Job job;
Job job2;
@RequestMapping("/launchjob")
public String handle() throws Exception {
Logger logger = LoggerFactory.getLogger(this.getClass());
try {
JobParameters jobParameters = new JobParametersBuilder().addLong("time", System.currentTimeMillis())
.toJobParameters();
jobLauncher.run(job, jobParameters);
jobLauncher.run(job2, jobParameters);
} catch (Exception e) {
logger.info(e.getMessage());
}
return "Done";
}
}
有解决此问题的建议吗?不知道我在想什么。
答案 0 :(得分:0)
您在@Autowired
上缺少job2
注释。