I'm using spring-batch for job executions. Does it matter on which class I place the @EnableBatchProcessing(modular = true) annotation?
I would place it on the global ApplicationConfig, or would it be better to put it on the modular batch configuration where the batch job execution context is created? Eg:
@Configuration
public class ModularBatchConfig {
@Bean
public ApplicationContextFactory myJob() {
return new GenericApplicationContextFactory(MyJob.class);
}
}
In an "application" that contains multiple batch jobs, we recommend putting the @EnableBatchProcessing at the highest level that makes sense. What I mean by that is that @EnableBatchProcessing is going to bootstrap a number of common components (JobRepository, TransactionManager, etc). It's typically better to use these as common components instead of bootstrapping one per job.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With