定时任务的实现方式

定时任务的实现方式

  1. Spring Scheduler(spring boot 默认整合了)
  2. Quartz(独立于 Spring 存在的定时任务框架)
  3. XXL-Job 之类的分布式任务调度平台(界面 + sdk)

第一种方式:

  1. 主类开启 @EnableScheduling
  2. 给要定时执行的方法添加 @ Scheduled 注解,指定 cron 表达式或者执行频率

不要去背 cron 表达式!

控制定时任务的执行以及分布式锁

https://www.cnblogs.com/techgy/p/17538810.html

posted @ 2023-07-03 21:22  AI未来10Y  阅读(15)  评论(0编辑  收藏  举报