1.问题总结
运行作业后,我看到 TABLE batch_step_context 像图片: 表的屏幕截图
FIELD short_context 的漂亮信息是:
{
"batch.taskletType": "com.a.b.job.config.BundleJobConfig$$Lambda$763/0x000000080070f840",
"batch.stepType": "org.springframework.batch.core.step.tasklet.TaskletStep"
}
如何在其中添加额外信息?
例如,工作完成后,我希望我的 FIELD short_context 是这样的:
{
"output": "hello world",
"batch.taskletType": "com.a.b.job.config.BundleJobConfig$$Lambda$763/0x000000080070f840",
"batch.stepType": "org.springframework.batch.core.step.tasklet.TaskletStep"
}
我怎样才能添加额外的信息,如“输出”。
2.我的代码的一部分
@Configuration
public class AJobConfig {
private final JobBuilderFactory jobBuilderFactory;
private final StepBuilderFactory stepBuilderFactory;
@Autowired
public AJobConfig(JobBuilderFactory jobBuilderFactory, StepBuilderFactory stepBuilderFactory) {
this.jobBuilderFactory = jobBuilderFactory;
this.stepBuilderFactory = stepBuilderFactory;
}
@Bean
public Job aJob(Step aStep) {
return jobBuilderFactory.get("aJob")
.start(aStep)
.build();
}
@Bean
public Step aStep() {
return stepBuilderFactory.get("aStep")
.tasklet((contribution, chunkContext) -> {
System.out.println("hi");
return RepeatStatus.FINISHED;
})
.build();
}
}