springboot的调度功能

  1. @Component
  2. public class ScheduledTasks {
  3. private static final SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
  4. /**
  5. * 任务调度,每隔1秒执行一次
  6. */
  7. @Scheduled(fixedRate = 1000)
  8. public void reportCurrentTime() {
  9. System.out.println("现在时间:" + dateFormat.format(new Date()));
  10. }
  11. }

启动的时候我们必须要在主函数类上加上注解:@EnableScheduling

  1. /**
  2. * SpringBoot使用任务调度
  3. * @EnableScheduling标注程序开启任务调度
  4. */
  5. @SpringBootApplication
  6. @EnableScheduling
  7. public class App {
  8. public static void main(String[] args) {
  9. SpringApplication.run(App.class, args);
  10. }
  11. }

quartz

https://blog.csdn.net/Alice_qixin/article/details/113802030
https://blog.csdn.net/noaman_wgs/article/details/80984873
https://blog.csdn.net/m0_45294725/article/details/102505737