一.

  1. @Configuration //1.主要用于标记配置类,兼备Component的效果。
  2. @EnableScheduling // 2.开启定时任务
  3. public class SaticScheduleTask {
  4. //3.添加定时任务
  5. @Scheduled(cron = "0/5 * * * * ?")
  6. //或直接指定时间间隔,例如:5秒
  7. //@Scheduled(fixedRate=5000)
  8. private void configureTasks() {
  9. System.err.println("执行静态定时任务时间: " + LocalDateTime.now());
  10. }
  11. }