Even if I add a method that adds `@ BeforeStep``` to
`Tasklet``` as shown below in spring-batch, it does not work as intended.
@Component
public class MyTasklet implements Tasklet {
@BeforeStep
void beforeStep(StepExecution stepExecution) {
System.out.println("asdfasdf");
}
Probably because there is no automatic listener registration in Tasklet
.
If you implement a listener such as StepExecutionListener in the implementation class such as ItemReader, that listener will also be automatically registered (at least for running spring-batch with spring-boot). See Spring-batch is automatically registered when listener is implemented by reader.
As mentioned above, it seems that ItemReader
has automatic listener registration, but `` `Tasklet``` does not. I'm just guessing because I haven't followed the source or documentation properly.
https://stackoverflow.com/questions/29935824/beforestep-annotated-method-not-being-called
Use the execute </ code> method argument
`chunkContext``` or implement
`StepExecutionListener```.
Recommended Posts