import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
@Configuration
@EnableScheduling
public class SpringScheduleConfig {
}
2.在需要使用的地方使用注解@Scheduled来配置任务的具体调度时间等import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@Component
public class TestTask {
@Scheduled(cron = "00 30 02 * * ?") // 每天02:30分执行博客自动审核任务
public void deleteUnUse() {
System.out.println("do somthing....");
}
}
https://blog.xqlee.com/article/75.html