java实现定时任务
新建一个springboot项目
在启动类加@EnableScheduling注解
@EnableScheduling
定义一个类用@Component 交给容器来管理
定义用方法来调用
在方法上加入这个注解 @Scheduled(cron ="0/2 * * * * ?")
@Component
#交给spring容器来管理
@Scheduled(cron ="0/2 * * * * ?")
cron的定时规则
0 0 10,1...
原创
2022-03-21 17:11:01 ·
424 阅读 ·
0 评论