SpringBoot编写一个SpringTask定时任务的方法
1,在启动类上添加注解
@EnableScheduling//开启定时任务调度
2, 任务(方法)上也要添加注解:
@Scheduled(cron =" 0 * * * * ? ") //每分钟执行一次 域: 秒 分 时 日 月 周 (年)
例:
@EnableScheduling//开启定时任务调度
@Scheduled(cron =" 0 * * * * ? ") //每分钟执行一次 域: 秒 分 时 日 月 周 (年)
例: