Skip to content
Advertisement

How to use DefaultJobParametersValidator in Java-configured Spring Batch application?

How can I use DefaultJobParametersValidator in a Java-based Spring Batch Application? Should I call it manually in a Tasklet? I cannot find any examples that does not used an xml configuration.

Advertisement

Answer

A JobParametersValidator is used to validate job parameters before every job execution. You do not call it manually, you need to register it in your job definition and Spring Batch will call it for you (this is how frameworks work). The DefaultJobParametersValidator will be used by default if you do not specify a custom validator.

The JobParametersValidator section in the reference documentation shows how to register a job parameter validator in both XML and Java configuration styles.

Advertisement