第二步:创建定时任务类(在这个类中使用cron表达式,来设置程序什么时间执行)@EnableScheduling // 开启定时任务
@Component
public class ScheduleTask {
@Scheduled(cron = "0/5 * * * * ?")
public void task1(){
System.out.println("task执行了");
}
}
cron表达式(设置执行的规则)在线Cron表达式生成器
在线Cron表达式生成器



