调用WebService接口(三)

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

上一集 我们扯到了 调用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.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值