6.1. @EnableBatchProcessing Discouraged

Previously, we could enable Spring Batch’s auto-configuration, annotating a configuration class with @EnableBatchProcessing. The new release of Spring Boot discourages the usage of this annotation if we want to use autoconfiguration.

In fact, using this annotation (or defining a bean that implements DefaultBatchConfiguration) tells the autoconfiguration to back off.

즉, @EnableBatchProcessing 애너테이션을 쓰게되면 BatchAutoConfiguration이 적용되지 않는다!

@ConditionalOnMissingBean(value = DefaultBatchConfiguration.class, annotation = EnableBatchProcessing.class)
public class BatchAutoConfiguration {


왜 이렇게 바뀌었을까? 아래 참조.


Note that @EnableBatchProcessing causing the auto-configuration to back off is a breaking change. In 2.x, this annotation was required to enable Boot's auto-configuration.

이런 중요한 내용은 docs에서 더 강조를 해줘... ㅠ;

With the recent changes in Batch we can change this to align with other areas, such as Spring MVC and WebFlux where @EnableWebMvc or @EnableWebFlux causes the respective auto-configuration to back off.



6.2. Running Multiple Jobs

Previously, it was possible to run multiple batch jobs at the same time using Spring Batch. However, this is no longer the case. If the auto-configuration detects a single job, it will be executed automatically when the application starts.

So if multiple jobs are present in the context, we'll need to specify which job should be executed on startup by providing the name of the job using the property. Therefore, this means that if we want to run multiple jobs, we have to create a separate application for each job.

Caused by: java.lang.IllegalArgumentException: Job name must be specified in case of multiple jobs
	at org.springframework.boot.autoconfigure.batch.JobLauncherApplicationRunner.validate