반응형
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시 실행");
}
}
반응형
'프로그램 관련 > spring' 카테고리의 다른 글
There is no statement named xxxx in this SqlMap 에러 해결법 (0) | 2018.09.07 |
---|---|
@RestController , @Controller 차이점입니다 (0) | 2018.09.06 |