Spring Boot定时任务配置

 

 

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

/**
 * @author yvioo
 */

@Component
@EnableScheduling   // 开启定时任务
public class ScheduleTask {

    /**
     *  corn表达式 
     * 每天0点执行
     */
    @Scheduled(cron = "0 0 0 */1 * ?")
    private void configureTasks() {
        System.err.println("定时任务执行");
    }
}

 

posted @ 2021-03-15 22:58  yvioo  阅读(198)  评论(0编辑  收藏  举报