cron表达式生成:
package com.xxx.task;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.text.SimpleDateFormat;
import java.util.Date;
@Component
@Configurable
@EnableScheduling
public class TimingTask {
@Scheduled(cron = "0 0 0/1 * * ? ")
public void reportCurrentByCron(){
System.out.println ("执行:" + dateFormat ().format(new Date()));
}
private SimpleDateFormat dateFormat(){
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
}
}