일정 주기로 로직 자동 실행

사용법(Spring Boot)

애플리케이션 엔트리 포인트에 @EnabledScheduling 추가

@SpringBootApplication
@EnableScheduling  // 이거 추가
public class Application {
    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}

메서드에 @Scheduled 를 붙여서 스케줄링 대상에 등록

@Scheduled(cron = "0 0 4 * * *")
public void scheduledMethod() {
    // 로직 작성...
}

cron 표현식 작성법

초 분 시 일 월 요일
*  *  *  *  *  *