springboot入门03 – 配置定时任务

概述

在Java环境下创建定时任务有多种方式:

  • 使用while循环配合Thread.sleep(),虽然稍嫌粗陋但也勉强可用
  • 使用TimerTimerTask
  • 使用ScheduledExecutorService
  • 定时任务框架,如Quartz

在SpringBoot下执行定时任务无非也就这几种方式(主要还是后两种)。只不过SpringBoot做了许多底层的工作,我们只…