代码
@Component
@EnableScheduling //开启定时任务
@Slf4j
@EnableAsync // 开启线程
public class Test {
@Scheduled(cron = "0/5 * * * * ?") //5 秒执行一次
@Async // 异步方法
public void testScheduleTask() {
System.out.println("执行定时任务" + LocalDateTime.now());
}
}