Trying to pass data from step1's processor to step2's processor (Spring Batch)

Viewed 27

I have followed this documentation: https://docs.spring.io/spring-batch/docs/current/reference/html/common-patterns.html#passingDataToFutureSteps

I'm trying to retrieve the information that I received from step1's processor in step2's processor.

Everything works If I have my @BeforeStep function in the writer class of step2. But I want to get the information in the processor class of step2. But in the processor class, @BeforeStep function doesn't even run.

Is this suppose to happen?? @BeforeStep only get hit in the writer class? or there is a way to get it in the processor class as well??

1 Answers

If you want the method annotated with @BeforeStep to be called, you need to declare your component as a Spring bean. Otherwise, you need to register it explicitly as a listener in your step.

Related