14. Spring Boot定时任务的使用【从零开始学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()");

    }

}

posted @ 2017-04-13 17:01  小学生II  阅读(196)  评论(0编辑  收藏  举报