게시글
질문&답변
JobStep 강의에서 childJob() 실행 질문
프로그램 변수 --job.name=parentjob1 job: names: ${job.name:NONE} # enabled: false@Slf4j @RequiredArgsConstructor @Configuration public class JobStepConfiguration { private final JobBuilderFactory jobBuilderFactory; private final StepBuilderFactory stepBuilderFactory; @Bean public Job parentJob(){ return jobBuilderFactory.get("parentJob1") .start(jobStep(null)) .next(step2()) .build(); } @Bean public Step jobStep(JobLauncher jobLauncher){ return stepBuilderFactory.get("jobStep1") .job(childJob()) .launcher(jobLauncher) .parametersExtractor(jobParametersExtractor()) .listener(new StepExecutionListener() { @Override public void beforeStep(StepExecution stepExecution) { stepExecution.getExecutionContext().putString("name", "user2"); } @Override public ExitStatus afterStep(StepExecution stepExecution) { return null; } }) .build(); } private DefaultJobParametersExtractor jobParametersExtractor() { DefaultJobParametersExtractor extractor = new DefaultJobParametersExtractor(); extractor.setKeys(new String[]{"name"}); return extractor; } @Bean public Job childJob(){ return jobBuilderFactory.get("childJob1") .start(step1()) .build(); } @Bean public Step step1(){ //TaskletStepBuilder return stepBuilderFactory.get("Step1") .tasklet((a, b) ->{ log.info("Step1 확인"); return RepeatStatus.FINISHED; }) .build(); } @Bean public Step step2(){ return stepBuilderFactory.get("Step2") .tasklet((a, b) ->{ log.info("Step2 확인"); return RepeatStatus.FINISHED; }) .build(); } }프로그램 변수로 인해서 parentJob1은 자동 실행 됩니다. 근데 childJob은 왜 자동 실행되는건가요?(강의 코드와 동일하고 결과도 동일합니다)
- 0
- 2
- 339
질문&답변
질문 있습니다!!
저도 궁금한데 아직도 답변이 안달려있네요 ㅠㅠ
- 0
- 2
- 195