Description
development environment
Spring Boot 3.3.4
Spring Batch 5.2.1
JDK 17
Spring Boot 3.0 Migration Guide
Previously, @EnableBatchProcessing could be used to enable Spring Boot’s auto-configuration of Spring Batch. It is no longer required and should be removed from applications that want to use Boot’s auto-configuration. A bean that is annotated with @EnableBatchProcessing or that extends Batch’s DefaultBatchConfiguration can now be defined to tell the auto-configuration to back off, allowing the application to take complete control of how Batch is configured.
Spring boot 3.0에서는 @EnableBatchProcessing
어노테이션을 권장하지 않는다고 한다. 그런데 해당 어노테이션을 사용하지 않으면 BeanPostProcessorChecker
warning이 발생한다. 또한, bean
으로 등록한 tasklet
은 실행하지 않는다.
그렇다고 @EnableBatchProcessing
를 사용하면 아래와 같은 에러가 발생한다. 마찬가지로 step에 등록한 tasklet은 실행되지 않는다.
Bean 'jobRegistry' of type [org.springframework.batch.core.configuration.support.MapJobRegistry] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). Is this bean getting eagerly injected into a currently created BeanPostProcessor [jobRegistryBeanPostProcessor]? Check the corresponding BeanPostProcessor declaration and its dependencies.
해당 warning은 spring batch 내부에서 동작하는 jobRegistryBeanPostProcessor
의 문제이다. 대안책으로 JobRegistrySmartInitializingSingleton
를 사용하는 것을 권장하고 있다. 이는 곧 나올 spring batch 5.2에서 개선될 예정이다.
Reference:
Spring Batch 5.0 Migration Guide
spring-batch/issues/4519
spring-batch/issues/4489
spring-batch/pull/4520
spring-batch/issues/4547