GitHub
src="//ghbtns.com/github-btn.html?user=je-ge&repo=spring-boot&type=watch&count=true" scrolling="0" width="110" height="20">注解 @Scheduled(cron = “0/5 * * * * ?”)
相当于原来的xml版本的如下配置
<task:scheduled ref="scheduledTask" method="getTask1" cron="0/5 * * * * ?" />
定时任务类ScheduledTask
package com.jege.spring.boot.task;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
/**
* @author JE哥
* @email 1272434821@qq.com
* @description:从配置文件加载任务信息
*/
@Component
public class ScheduledTask