每次都执行很多次
import java.text.SimpleDateFormat;
import java.util.Date;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@Component
public class CsTask {
@Scheduled(cron = "0/10 * * * * ?")
public void taskCron(){
SimpleDateFormat simpleDateFormat = new SimpleDateFormat();
simpleDateFormat.applyPattern("yyyy-MM-dd HH:mm:ss");
String sdf = simpleDateFormat.format(new Date());
System.out.println("cron: " + sdf);
}
}
直接复制粘贴你的代码
重新build/重启/重写应该可解