Stotra
Stotra

Reputation: 103

Understanding Scope of Job/Step in Spring Batch

I am working on a spring batch project. I am confused if I should make a Step @StepScoped or Application scoped.

If a Step is Application Scope, I guess the Readers/Writers/Processors Can be both application scoped and StepScoped. Is that right?

Also, I am planning of organizing the Steps in a list and try to check if all the tests in the list are created or not and vice versa, for the same I will have to make the steps application scoped so that on application startup I can check if the step are configured properly as per my list. Is this correct way to do this?

TIA

Upvotes: 0

Views: 397

Answers (1)

Mahmoud Ben Hassine
Mahmoud Ben Hassine

Reputation: 31640

It does not make sense to make a step bean step-scoped. The components of the step (reader, writer, tasklet, etc) can be step-scoped, but not the step itself.

There is a note about this in the reference documentation here.

Upvotes: 0

Related Questions