1.在SpringBoot的启动类Appilcation上声明:
@EnableScheduling
2.添加定时任务
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@Component
public class ScheduledTasks {
//每天凌晨一点执行
@Scheduled(cron = "0 0 1 * * ?")
public void bigScreenScheduledTasks(){
System.out.println("每天凌晨一点执行定时任务");
}
}