Implementing StepExecutionListener is one way. In fact that's the only way in Spring Batch 1.x.
Starting from Spring Batch 2, you have another choice: You can inject whatever entries in Job Parameters and Job Execution Context to your item writer. Make your item writer with step
scope, then make use of expression like #{jobParameters['theKeyYouWant']}
or #{jobExecutionContext['someOtherKey']}
for value injecting to you item writer.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…