프로그램 관련/spring
spring boot Scheduled (스케쥴러 사용하기)
SeoHW
2022. 6. 14. 16:20
반응형
spring boot Scheduled (스케쥴러 사용하기)
application claas 에 @EnableScheduling 추가하기
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication
@EnableScheduling
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
1. @Component 추가하기
2. @Scheduled 추가하기
@Component
public class Schedule{
@Scheduled(cron="0 0 0 1 * *") //매달1일 00시 실행
public void scheduleTest(){
System.out.println("매달1일 00시 실행");
}
}
반응형