spring boot @Schduled 定时任务使用方法

@[技术交流]springboot 使用定时任务@Scheduled

spring boot @Schduled 定时任务使用方法

最近在做项目的时候,遇到了一个问题,需要在项目中添加了定时任务的功能。spring boot的 @Schduled标签能够轻松的制定任务,但是我们看网络上的教程需要配置xml文件,非常的麻烦,所以我找到一个不需要直接通过注解启动的任务的方法,分享给大家。

步骤一 在启动类上添加@EnableScheduling注解

步骤一

步骤二 新建定时任务类


1.新建定时任务类。
2.添加component 注解。
3.新建方法,添加@Scheduled注解。
4.参数cron是关于执行时间的,如何设置时间,待补充。

猜你喜欢

转载自blog.csdn.net/fanyunxing/article/details/86594408