上一集 我们扯到了 调用WebService接口,并且成功拿到了接口返回和JavaBean。
https://blog.csdn.net/weixin_44458365/article/details/106993689
这一集我们说关于定时任务的配置创建。
先说说我们的定时任务。
项目需求:
1、接口需要提供给前端。
2、前端页面可以配置定时任务的启停。
3、前端页面可以配置定时任务的执行频率。
1、在启动器上加注解
@EnableScheduling
2、编写代码
package up.tour.link.task;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.Trigger;
import org.springframework.scheduling.TriggerContext;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.scheduling.support.CronTrigger;
import org.springframework.stereotype.Component;
import up.tour.link.service.

本文主要介绍了在Spring Boot项目中如何配置和创建定时任务,以实现动态控制调用WebService接口的启停。通过@EnableScheduling注解启用定时任务,编写任务代码,并在Controller中注入,实现了前端配置定时任务执行频率和启停的功能。
最低0.47元/天 解锁文章
1081

被折叠的 条评论
为什么被折叠?



