当前位置:网站首页>Hutool dynamically adds scheduled tasks
Hutool dynamically adds scheduled tasks
2022-07-03 03:33:00 【Today, the flowers are sad】
introduce hutool
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.6.5</version>
</dependency>In the startup class (springboot project ) Add the following code :
// Second level timing tasks are supported
CronUtil.setMatchSecond(true);
// The scheduled service starts
CronUtil.start();

After triggering, the background execution logic
// Start timing task
@GetMapping("/start")
public String start() {
// Dynamically add scheduled tasks , Because the scheduled service has been started when the project is started , So after adding cron Execute when the condition is triggered
String jobId = CronUtil.schedule("0/1 * * * * ? ", new Task() {
@Override
public void execute() {
System.out.println(" Scheduled task execution ");
}
});
if (!StringUtils.isEmpty(jobId)) {
return jobId;
} else {
return null;
}
}
// Stop the corresponding scheduled task
@GetMapping("/stop/{jobid}")
public void stop(@PathVariable("jobid")String jobid) {
CronUtil.remove(jobid);
}边栏推荐
- Mongodb replication set [master-slave replication]
- Limit of one question per day
- 渤、黄海的潮汐特征
- npm : 无法将“npm”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。
- Introduction à mongodb
- docker安装及启动mysql服务
- Lvgl usage experience
- Vs 2019 configuration du moteur de génération de tensorrt
- [combinatorics] basic counting principle (addition principle | multiplication principle)
- Application of derivative in daily question
猜你喜欢

Table structure of Navicat export database

Nanning water leakage detection: warmly congratulate Guangxi Zhongshui on winning the first famous brand in Guangxi

Vs 2019 installation and configuration opencv

Summary of electromagnetic spectrum

为什么线程崩溃不会导致 JVM 崩溃

Captura下载安装及在Captura配置FFmpeg

Vs 2019 configuration tensorrt
![[MySQL] the difference between left join, right join and join](/img/d4/8684cd59cd1bd77e70bd4d7c7074c3.jpg)
[MySQL] the difference between left join, right join and join

Small guide for rapid formation of manipulator (VIII): kinematic modeling (standard DH method)

Download and install node, NPM and yarn
随机推荐
redis在服务器linux下的启动的相关命令(安装和配置)
@Accessors annotation function specifies that the prefix follows the hump naming
Hi3536c v100r001c02spc040 cross compiler installation
BigVision代码
Limit of one question per day
[mathematical logic] normal form (conjunctive normal form | disjunctive normal form | major item | minor item | maximal item | minor item | principal conjunctive normal form | principal disjunctive no
sigaction的使用
VS克隆时显示403错误
labelimg生成的xml文件转换为voc格式
Pytoch configuration
UMI route interception (simple and rough)
[set theory] partial order relation (partial order relation definition | partial order set definition | greater than or equal to relation | less than or equal to relation | integer division relation |
Change and access of median value of listening object
MongoDB复制集【主从复制】
The difference between static web pages and dynamic web pages & the difference between Web1.0 and Web2.0 & the difference between get and post
PHP generates PDF tcpdf
User value is the last word in the competition of mobile phone market
动态规划:最长公共子串和最长公共子序列
Applet (continuous update)
Idea set method call ignore case