- 在主启动类当中引入Spring Task
@SpringBootApplication
@EnableScheduling //引入Spring Task
public class PaymentDemoApplication {
public static void main(String[] args) {
SpringApplication.run(PaymentDemoApplication.class, args);
}
}
- 测试例子 在@Scheduled中指定定时的频率
@Scheduled(cron = "* * * * * ?")
public void task1() {
log.info("task1 被执行...");
}



