Springboot定时任务
1)方法上加入原注解:
@Scheduled(cron = "0/30 * * * * ? ")
2)类加原注解:
@EnableScheduling
//导包:
//import org.springframework.scheduling.annotation.EnableScheduling;
//import org.springframework.scheduling.annotation.Scheduled;
测试:
//定时任务,30秒执行一次
System.err.println("执行静态定时任务时间: " + LocalDateTime.now());