package com.rick.common.schedule;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import java.text.SimpleDateFormat;
import java.util.Calendar;
/**
* Desc : 定时任务
* User : RICK
* Time : 2017/8/21 21:16
*/
@Configuration
@EnableScheduling
public class DemoSchedule {
//cron表达式 秒分时 日月周 年
@Scheduled(cron = "0/10 * * * * ?") //每10秒执行一次
public void demoPrint(){
System.out.println("现在时间:" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Calendar.getInstance().getTime()));
}
}