JSCODE Logo
블로그후기멘토진
회사명 : JSCODE대표 : 박재성사업자 등록번호 : 244-22-01557통신판매업 : 제 2023-인천미추홀-0381 호
학원 명칭 : 제이에스코드(JSCODE)원격학원학원설립ㆍ운영 등록번호 : 제6063호

서울특별시 구로구 경인로 20가길 11(오류동, 아델리아)

Copyright ⓒ 2025 JSCODE - 최상위 현업 개발자들의 프로그래밍 교육 All rights reserved.

이용약관개인정보처리방침
← 블로그 목록으로 돌아가기

[실습] 스케줄러 등록하기

JSCODE 시니
JSCODE 시니
2026. 04. 04.
author
JSCODE 시니
category
Spring Batch
createdAt
Feb 7, 2026 01:13 AM
isPublic
isPublic
series
Spring Batch 입문: 3시간 만에 끝내는 대용량 처리의 기초
slug
configuring-spring-batch-scheduler
type
post
updatedAt
Apr 4, 2026 10:00

✅ 1. 스케줄러 클래스 구현

JobScheduler.java
package com.batch.settlement.scheduler; @Slf4j @Component @RequiredArgsConstructor public class JobScheduler { // 스프링 배치 6버전 변경 사항 private final JobOperator jobOperator; private final Job settlementJob; //@Scheduled(cron = "0 0 4 * * *") //@Scheduled(cron = "0/10 * * * * *") @Scheduled(cron = "0 30 13 * * *") public void runJob(){ String jobName = "settlementJob"; try{ JobParameters jobParameters = new JobParametersBuilder() .addString("targetDate", LocalDate.now().minusDays(7).toString()) .addLong("time", System.currentTimeMillis()) // 중복 방지 .toJobParameters(); log.info("스케줄러 작동! 배치를 실행합니다."); jobOperator.start(settlementJob, jobParameters); } catch (JobInstanceAlreadyCompleteException e) { log.error("배치 실행 중 예외가 발생했습니다.", e); } catch (InvalidJobParametersException e) { log.error("배치 실행 중 예외가 발생했습니다.", e); } catch (JobExecutionAlreadyRunningException e) { log.error("배치 실행 중 예외가 발생했습니다.", e); } catch (JobRestartException e) { log.error("배치 실행 중 예외가 발생했습니다.", e); } catch (Exception e){ log.error("알 수 없는 에러 발생"); } } }
 
 

✅ 2. 메인 메소드 수정

SettlementApplication.java
package com.batch.settlement; @EnableScheduling @SpringBootApplication public class SettlementApplication { public static void main(String[] args) { SpringApplication.run(SettlementApplication.class, args); } }
 
 

✅ 3. 실행 확인

notion image
 
author
category
Spring Batch
createdAt
Mar 5, 2026 10:56 PM
isPublic
isPublic
series
Spring Batch 입문: 3시간 만에 끝내는 대용량 처리의 기초
slug
type
series-footer
updatedAt
Apr 4, 2026 10:00
📎
이 글은 Spring Batch 입문 강의의 수업 자료 중 일부입니다.