Spring-batch中的作业将在表BATCH_JOB_EXECUTION
中保存该作业的状态。是否有一种简单的方法(除了读取表本身中的列START_TIME
之外)还可以从“步骤”中获取作业的开始时间?
答案 0 :(得分:1)
是的,从步骤执行中访问作业执行的想法。例如:
@Bean
public Step step() {
return stepBuilderFactory.get("step")
.tasklet(new Tasklet() {
@Override
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
JobExecution jobExecution = chunkContext.getStepContext().getStepExecution().getJobExecution();
System.out.println("hello world! Job started at: " + jobExecution.getStartTime());
return RepeatStatus.FINISHED;
}
})
.build();
}