Reputation: 86657
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);
}
}
Upvotes: 4
Views: 12203
Reputation: 21453
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.
Upvotes: 4