Reputation: 55
My Spring Batch job uses a FlatFileItemReader
to read .csv files. To implement error handling, I created a custom ItemReadListener
and provided an overridden onReadError
implementation.
Here, I'd like access to the StepName
and StepExecutionId
from which the error was thrown (i.e. at the reader level). Can I access the StepExecution
in the my custom listener? When I try to inject it into any method or constructor, I get a "No beans of type StepExecution found" error.
Thanks.
Upvotes: 1
Views: 2204
Reputation: 784
Try with the following in your ItemReadListener.
@Value("#{stepExecution}")
private StepExecution stepExecution;
This should work if the scope is step. Also your ItemReadListener should be a spring bean.
Upvotes: 3