您的位置:首页 > 编程语言 > Java开发

14. Spring Boot定时任务的使用【从零开始学Spring Boot】

2016-12-28 17:29 621 查看
本文介绍在 spring Boot 中如何使用定时任务,使用非常简单,就不做过多说明了。

com.kfit.base.scheduling.SchedulingConfig:

package com.kfit.base.scheduling;
 
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
 
/**
 * 定时任务
 * @author Administrator
 *
 */
@Configuration
@EnableScheduling
publicclass SchedulingConfig {
   
    @Scheduled(cron = "0/20 * * * * ?") // 每20秒执行一次
    publicvoid scheduler() {
        System.out.println(">>>>>>>>> SchedulingConfig.scheduler()");
    }
}

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: