Spirngboot使用定时任务

48 阅读1分钟

Spirngboot使用定时任务

  1. 启动类增加@EnableScheduling注解
  2. 新增业务类,代码如下
@Component
public class TimmerTest{

    # 每10秒执行一次
    @Scheduled(cron = "0/10 * * * * ?")
    public void timmer(){
        System.out.println("定时任务执行了!");
    }
  
}