inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

스프링 배치

어플리케이션 예제 (2)

5.0 버전으로 마이그레이션

1364

김도연

작성한 질문수 1

0

기존에 하던 프로젝트의 스프링 버전이 3.0.0이라 배치의 버전 또한 5.0을 사용하게 됐습니다. excute 메소드가 실행되지 않는 이유를 알 수 있을까요..??


package com.jojoldu.book.freelecspringbootwebservice.config;

import lombok.RequiredArgsConstructor;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.Step;
import org.springframework.batch.core.StepContribution;
import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;
import org.springframework.batch.core.configuration.support.DefaultBatchConfiguration;
import org.springframework.batch.core.job.builder.JobBuilder;
import org.springframework.batch.core.repository.JobRepository;
import org.springframework.batch.core.scope.context.ChunkContext;
import org.springframework.batch.core.step.builder.StepBuilder;
import org.springframework.batch.core.step.tasklet.Tasklet;
import org.springframework.batch.repeat.RepeatStatus;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


@Configuration
@EnableBatchProcessing
@RequiredArgsConstructor
public class HelloJobConfiguration extends DefaultBatchConfiguration {

    @Bean
    public Job myJob(JobRepository jobRepository, Step myStep1, Step myStep2) {
        System.out.println("this is job");
        return new JobBuilder("myJob", jobRepository)
                .start(myStep1)
                .next(myStep2)
                .build();
    }

    @Bean
    public Step myStep1(JobRepository jobRepository) {
        System.out.println("this is step1");
        return new StepBuilder("myStep1", jobRepository)
                .tasklet(new Tasklet() {
                    @Override
                    public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
                        System.out.println("step1 started");
                        return RepeatStatus.FINISHED;
                    }
                }, getTransactionManager())
                .build();
    }

    @Bean
    public Step myStep2(JobRepository jobRepository) {
        System.out.println("this is step2");
        return new StepBuilder("myStep2", jobRepository)
                .tasklet(new Tasklet() {
                    @Override
                    public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
                        System.out.println("step2 started");
                        return RepeatStatus.FINISHED;
                    }
                }, getTransactionManager())
                .build();
    }
}

spring-boot spring-batch

답변 2

1

정수원

강의에서 제공하는 소스와는 많이 다른 것 같습니다.

소스를 실행해 봐야 정확한 원인을 알 수 있을 것 같습니다.

소스 공유 가능할까요?

그리고 버전차이로 인한 부분은 저도 자세하게 살펴보지 않았기 때문에 정확한 답변이 어려울 수 있는점 양해 부탁드립니다.

0

infitry

@EnableBatchProcessing 어노테이션을 제외하시면 됩니다.
스프링 배치 5.x 에서는 더이상 @EnableBatchProcessing 어노테이션을 필요하지 않게 되었습니다.

https://github.com/spring-projects/spring-batch/issues/4232

스프링 배치 버전 질문

0

122

1

소스코드가 어디에 있나요?

0

96

2

트랜잭션 예외

0

92

1

질문이 있습니다.

0

130

2

ChunkListener 에서 beforeChunk 의 실행 시점 관련 질문

0

125

2

여러 JOB 설정하는법

0

150

2

강의 자료 다른 방법 있을까요?

0

154

1

JobExecution과 JobExecutionContext와의 관계

0

186

2

특정 job만 실행

1

252

1

Batch 성능 질문

0

153

1

ItemReaderAdapter 종료

0

80

1

[ 강좌 Git 브랜치 문의 ] 섹션 9 > JdbcCursorItemReader, JpaCursorItemReader

0

179

2

Spring Batch 배포 질문

0

246

2

spring batch 버전

0

236

2

retry count 관련 질문

0

172

2

StepExecutionListener 의 afterStep 에서 return ExitStatus.FAILED 에 의한 동작에 의문이 갑니다.

0

330

2

jdbc, jpa 커서방식 조회 방식 차이 질문 (강사님께 답변 받고 싶습니다)

0

235

2

Multithread step과 AsyncItemProcessor

0

203

2

job 재실행

0

251

2

bean 생명주기 문제 도와주세요(@Scope("step"), @Autowired)

0

183

1

Multi-threaded-step과 Partitioning 차이 확인

0

175

2

jdbcCursorReader, jdbcPagingReader 질문

0

146

1

step muti-thread 질문

0

111

1

itemSteam open update close 질문

0

112

1