[九]SpringBoot 之 定时任务

代码:

package me.shijunjie.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

@Configuration
@EnableScheduling
public class SchedulingConfig {
    
    @Scheduled(cron = "0/5 * * * * ?") // 每20秒执行一次
    public void testSchedule() {
          System.out.println(">>>>>>>>> SchedulingConfig.scheduler()");
    }
}

效果

 

posted @ 2017-03-01 16:07  GodTelMe  阅读(512)  评论(0编辑  收藏  举报