에러

spring batch 5.0 JobBuilderFactory, StepBuilderFactory

integerJI 2024. 11. 24. 10:36
'org.springframework.batch.core.configuration.annotation.StepBuilderFactory' is deprecated since version 5.0.0 and marked for removal

 

'org.springframework.batch.core.configuration.annotation.JobBuilderFactory' is deprecated since version 5.0.0 and marked for removal

 

Spring Batch 5.0 이상부턴 JobBuilderFactory, StepBuilderFactory을 사용하려면 해당 경고문이 나온다.

 

https://github.com/spring-projects/spring-batch/wiki/Spring-Batch-5.0-Migration-Guide

 

Spring Batch 5.0 Migration Guide

Spring Batch is a framework for writing batch applications using Java and Spring - spring-projects/spring-batch

github.com

 

공식 문서를 보면

 

JobBuilderFactory

// Sample with v5
@Configuration
@EnableBatchProcessing
public class MyJobConfig {

    @Bean
    public Job myJob(JobRepository jobRepository, Step step) {
        return new JobBuilder("myJob", jobRepository)
                .start(step)
                .build();
    }

}

 

StepBuilderFactory

// Sample with v5
@Configuration
@EnableBatchProcessing
public class MyStepConfig {

    @Bean
    public Tasklet myTasklet() {
       return new MyTasklet();
    }

    @Bean
    public Step myStep(JobRepository jobRepository, Tasklet myTasklet, PlatformTransactionManager transactionManager) {
        return new StepBuilder("myStep", jobRepository)
                .tasklet(myTasklet, transactionManager) // or .chunk(chunkSize, transactionManager)
                .build();
    }

}

 

이렇게 사용하라고 가이드가 나온다.

 

정리하자면

 

JobBuilderFactory -> JobRepository