SpringBoot设置定时任务
作者:互联网
package com.sporch.controller; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; @Component @EnableScheduling //开启对定时任务的支持 public class ActivitiController { @Scheduled(cron="0/20 * * * * ?") //cron表达式 20秒执行一次 public void scheduler() { System.out.println("定时任务执行了"); } }
标签:SpringBoot,springframework,cron,EnableScheduling,设置,org,import,定时 来源: https://www.cnblogs.com/chengzhongyi/p/10441505.html