ScheduledTask.java
742 Bytes
package com.infoloop.tianting.task;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@Component
@EnableScheduling
public class ScheduledTask {
// 每5秒执行一次的定时任务
// @Scheduled(fixedRate = 5000)
// public void task1() {
// System.out.println("定时任务1:每5秒执行一次,当前时间:" + System.currentTimeMillis());
// }
// 每天凌晨2点执行一次的定时任务
@Scheduled(cron = "0 0 2 * * *")
public void taskForUpdateOrderStatus() {
System.out.println("定时任务2:每天凌晨2点执行一次,当前时间:" + System.currentTimeMillis());
}
}