当前位置:网站首页>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);
}边栏推荐
- [Chongqing Guangdong education] cultural and natural heritage reference materials of China University of Geosciences (Wuhan)
- 基于Qt的yolov5工程
- Summary of matrix knowledge points in Chapter 2 of Linear Algebra (Jeff's self perception)
- Some preliminary preparations for QQ applet development: make an appointment for a development account, download and install developer tools, and create QQ applet
- VS 2019 配置tensorRT生成engine
- [embedded module] OLED display module
- redis在服务器linux下的启动的相关命令(安装和配置)
- Solve high and send system Currenttimemillis Caton
- @Accessors annotation function specifies that the prefix follows the hump naming
- Yolov5 project based on QT
猜你喜欢

node,npm以及yarn下载安装

Summary of electromagnetic spectrum
![C programming learning notes [edited by Mr. Tan Haoqiang] (Chapter III sequence programming) 03 operators and expressions](/img/4a/1df03d9f3315debb4c335260ed39f2.jpg)
C programming learning notes [edited by Mr. Tan Haoqiang] (Chapter III sequence programming) 03 operators and expressions

Elsevier latex submitted the article pdftex def Error: File `thumbnails/cas-email. jpeg‘ not found: using draf

FileZilla Client下載安裝

Vs 2019 configure tensorrt to generate engine

softmax的近似之NCE详解
![[MySQL] the difference between left join, right join and join](/img/d4/8684cd59cd1bd77e70bd4d7c7074c3.jpg)
[MySQL] the difference between left join, right join and join

Tidal characteristics of the Bohai Sea and the Yellow Sea

FileZilla Client下载安装
随机推荐
FileZilla client download and installation
Pytoch lightweight visualization tool wandb (local)
Change and access of median value of listening object
Advanced redis applications [password protection, data persistence, master-slave synchronization, sentinel mode, transactions] [not completed yet (semi-finished products)]
Basic operations of mongodb [add, delete, modify, query]
Introduction à mongodb
Téléchargement et installation du client Filezilla
Using jasmine to monitor constructors - spying on a constructor using Jasmine
[leetcode question brushing day 34] 540 Unique element in array, 384 Disrupt array, 202 Happy number, 149 Maximum number of points on a line
Limit of one question per day
Captura下载安装及在Captura配置FFmpeg
使用InputFilter限制EditText时踩坑及解决方案
MongoDB简介
【AI实战】应用xgboost.XGBRegressor搭建空气质量预测模型(一)
npm : 无法将“npm”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。
用Three.js做一個簡單的3D場景
可分离债券与可转债
FileZilla Client下載安裝
Open Visual Studio 2010 hangs when opening a SQL file sql file
Vs 2019 configuration du moteur de génération de tensorrt