SpringBoot实现定时任务,使用自带的定时任务以及调度框架quartz的配置使用

embedded/2025/1/25 3:47:30/

SpringBoot实现定时任务,使用自带的定时任务以及调度框架quartz的配置使用

文章目录

  • SpringBoot实现定时任务,使用自带的定时任务以及调度框架quartz的配置使用
    • 一. 使用SpringBoot自带的定时任务(适用于小型应用)
    • 二. 使用调度框架quartz(适用于中大型应用)
    • 三、数据库模式quartz的使用
        • 1. 创建数据库表
        • 2. 制定一个定时任务
        • 3. 写配置文件
        • 4. 创建接收和相应实体类
        • 5. 增删改查的controller层接口
        • 6. 编写接口测试代码

一. 使用SpringBoot自带的定时任务(适用于小型应用)

创建SpringBoot项目,创建SpringBootTestJob 类,作为定时任务类

java"> @Component@EnableSchedulingpublic class SpringBootTestJob {@Scheduled(cron = "0/5 * * * * ?") // 每五秒执行一次private void test() {System.out.println("SpringBootTestJob TEST");}}
  • 适用性: 适合单体应用,不适合集群,没法实时更改定时任务状态和策略

启动后,可以看到,每五秒打印内容:
在这里插入图片描述

二. 使用调度框架quartz(适用于中大型应用)

  1. 增加依赖
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-quartz</artifactId>
</dependency>
  1. 创建定时任务类
java">import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;/*** @author SaoE* @date 2025/1/19 20:06*/
public class TestJob implements Job {@Overridepublic void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {System.out.println("TestJob TEST");}
}
  1. 增加quartz配置类QuartzConfig
java"> @Configurationpublic class QuartzConfig {/*** 声明一个任务* @return*/@Beanpublic JobDetail jobDetail() {return JobBuilder.newJob(TestJob.class).withIdentity("TestJob", "test").storeDurably().build();}/*** 声明一个触发器,什么时候触发这个任务* @return*/@Beanpublic Trigger trigger() {return TriggerBuilder.newTrigger().forJob(jobDetail()).withIdentity("trigger", "trigger").startNow().withSchedule(CronScheduleBuilder.cronSchedule("*/2 * * * * ?")).build();}}
  1. 启动主类
    可以看到控制台每两秒打印信息:
    在这里插入图片描述
  2. 禁止任务并发执行
    任务类增加注解@DisallowConcurrentExecution,修改如下:
java">@DisallowConcurrentExecution
public class TestJob implements Job {@Overridepublic void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {System.out.println("TestJob TEST开始");try {Thread.sleep(3000);} catch (InterruptedException e) {e.printStackTrace();}System.out.println("TestJob TEST结束");}
}

此时打印输出为上一个任务结束后,下一个任务立即开始。如果没有这个注解,则会并发执行。

三、数据库模式quartz的使用

1. 创建数据库表
-- #
-- # Quartz seems to work best with the driver mm.mysql-2.0.7-bin.jar
-- #
-- # PLEASE consider using mysql with innodb tables to avoid locking issues
-- #
-- # In your Quartz properties file, you'll need to set
-- # org.quartz.jobStore.driverDelegateClass = org.quartz.impl.jdbcjobstore.StdJDBCDelegate
-- #
DROP TABLE IF EXISTS QRTZ_FIRED_TRIGGERS;
DROP TABLE IF EXISTS QRTZ_PAUSED_TRIGGER_GRPS;
DROP TABLE IF EXISTS QRTZ_SCHEDULER_STATE;
DROP TABLE IF EXISTS QRTZ_LOCKS;
DROP TABLE IF EXISTS QRTZ_SIMPLE_TRIGGERS;
DROP TABLE IF EXISTS QRTZ_SIMPROP_TRIGGERS;
DROP TABLE IF EXISTS QRTZ_CRON_TRIGGERS;
DROP TABLE IF EXISTS QRTZ_BLOB_TRIGGERS;
DROP TABLE IF EXISTS QRTZ_TRIGGERS;
DROP TABLE IF EXISTS QRTZ_JOB_DETAILS;
DROP TABLE IF EXISTS QRTZ_CALENDARS;
CREATE TABLE QRTZ_JOB_DETAILS
(SCHED_NAME VARCHAR(120) NOT NULL  comment '定时任务名称',JOB_NAME  VARCHAR(200) NOT NULL  comment 'job名称',JOB_GROUP VARCHAR(200) NOT NULL  comment 'job组',DESCRIPTION VARCHAR(250) NULL  comment '描述',JOB_CLASS_NAME   VARCHAR(250) NOT NULL  comment 'job类名',IS_DURABLE VARCHAR(1) NOT NULL  comment '是否持久化',IS_NONCONCURRENT VARCHAR(1) NOT NULL  comment '是否非同步',IS_UPDATE_DATA VARCHAR(1) NOT NULL  comment '是否更新数据',REQUESTS_RECOVERY VARCHAR(1) NOT NULL  comment '请求是否覆盖',JOB_DATA BLOB NULL  comment 'job数据',PRIMARY KEY (SCHED_NAME,JOB_NAME,JOB_GROUP)
);
CREATE TABLE QRTZ_TRIGGERS
(SCHED_NAME VARCHAR(120) NOT NULL  comment '定时任务名称',TRIGGER_NAME VARCHAR(200) NOT NULL comment '触发器名称',TRIGGER_GROUP VARCHAR(200) NOT NULL  comment '触发器组',JOB_NAME  VARCHAR(200) NOT NULL  comment 'job名称',JOB_GROUP VARCHAR(200) NOT NULL  comment 'job组',DESCRIPTION VARCHAR(250) NULL  comment '描述',NEXT_FIRE_TIME BIGINT(13) NULL  comment '下一次触发时间',PREV_FIRE_TIME BIGINT(13) NULL  comment '前一次触发时间',PRIORITY INTEGER NULL  comment '等级',TRIGGER_STATE VARCHAR(16) NOT NULL  comment '触发状态',TRIGGER_TYPE VARCHAR(8) NOT NULL  comment '触发类型',START_TIME BIGINT(13) NOT NULL  comment '开始时间',END_TIME BIGINT(13) NULL  comment '结束时间',CALENDAR_NAME VARCHAR(200) NULL  comment '日程名称',MISFIRE_INSTR SMALLINT(2) NULL  comment '未触发实例',JOB_DATA BLOB NULL  comment 'job数据',PRIMARY KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP),FOREIGN KEY (SCHED_NAME,JOB_NAME,JOB_GROUP)REFERENCES QRTZ_JOB_DETAILS(SCHED_NAME,JOB_NAME,JOB_GROUP)
);
CREATE TABLE QRTZ_SIMPLE_TRIGGERS
(SCHED_NAME VARCHAR(120) NOT NULL  comment '定时任务名称',TRIGGER_NAME VARCHAR(200) NOT NULL  comment '触发器名称',TRIGGER_GROUP VARCHAR(200) NOT NULL  comment '触发器组',REPEAT_COUNT BIGINT(7) NOT NULL  comment '重复执行次数',REPEAT_INTERVAL BIGINT(12) NOT NULL  comment '重复执行间隔',TIMES_TRIGGERED BIGINT(10) NOT NULL  comment '已经触发次数',PRIMARY KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP),FOREIGN KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)REFERENCES QRTZ_TRIGGERS(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)
);
CREATE TABLE QRTZ_CRON_TRIGGERS
(SCHED_NAME VARCHAR(120) NOT NULL  comment '定时任务名称',TRIGGER_NAME VARCHAR(200) NOT NULL  comment '触发器名称',TRIGGER_GROUP VARCHAR(200) NOT NULL  comment '触发器组',CRON_EXPRESSION VARCHAR(200) NOT NULL  comment 'cron表达式',TIME_ZONE_ID VARCHAR(80)  comment '时区',PRIMARY KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP),FOREIGN KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)REFERENCES QRTZ_TRIGGERS(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)
);
CREATE TABLE QRTZ_SIMPROP_TRIGGERS
(SCHED_NAME VARCHAR(120) NOT NULL  comment '定时任务名称',TRIGGER_NAME VARCHAR(200) NOT NULL  comment '触发器名称',TRIGGER_GROUP VARCHAR(200) NOT NULL  comment '触发器组',STR_PROP_1 VARCHAR(512) NULL  comment '开始配置1',STR_PROP_2 VARCHAR(512) NULL  comment '开始配置2',STR_PROP_3 VARCHAR(512) NULL  comment '开始配置3',INT_PROP_1 INT NULL  comment 'int配置1',INT_PROP_2 INT NULL  comment 'int配置2',LONG_PROP_1 BIGINT NULL  comment 'long配置1',LONG_PROP_2 BIGINT NULL  comment 'long配置2',DEC_PROP_1 NUMERIC(13,4) NULL  comment '配置描述1',DEC_PROP_2 NUMERIC(13,4) NULL  comment '配置描述2',BOOL_PROP_1 VARCHAR(1) NULL  comment 'bool配置1',BOOL_PROP_2 VARCHAR(1) NULL  comment 'bool配置2',PRIMARY KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP),FOREIGN KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)REFERENCES QRTZ_TRIGGERS(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)
);
CREATE TABLE QRTZ_BLOB_TRIGGERS
(SCHED_NAME VARCHAR(120) NOT NULL  comment '定时任务名称',TRIGGER_NAME VARCHAR(200) NOT NULL  comment '触发器名称',TRIGGER_GROUP VARCHAR(200) NOT NULL  comment '触发器组',BLOB_DATA BLOB NULL  comment '数据',PRIMARY KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP),FOREIGN KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)REFERENCES QRTZ_TRIGGERS(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)
);
CREATE TABLE QRTZ_CALENDARS
(SCHED_NAME VARCHAR(120) NOT NULL  comment '定时任务名称',CALENDAR_NAME  VARCHAR(200) NOT NULL comment '日程名称',CALENDAR BLOB NOT NULL  comment '日程数据',PRIMARY KEY (SCHED_NAME,CALENDAR_NAME)
);
CREATE TABLE QRTZ_PAUSED_TRIGGER_GRPS
(SCHED_NAME VARCHAR(120) NOT NULL  comment '定时任务名称',TRIGGER_GROUP  VARCHAR(200) NOT NULL  comment '触发器组',PRIMARY KEY (SCHED_NAME,TRIGGER_GROUP)
);
CREATE TABLE QRTZ_FIRED_TRIGGERS
(SCHED_NAME VARCHAR(120) NOT NULL  comment '定时任务名称',ENTRY_ID VARCHAR(95) NOT NULL  comment 'entryId',TRIGGER_NAME VARCHAR(200) NOT NULL  comment '触发器名称',TRIGGER_GROUP VARCHAR(200) NOT NULL  comment '触发器组',INSTANCE_NAME VARCHAR(200) NOT NULL  comment '实例名称',FIRED_TIME BIGINT(13) NOT NULL  comment '执行时间',SCHED_TIME BIGINT(13) NOT NULL  comment '定时任务时间',PRIORITY INTEGER NOT NULL  comment '等级',STATE VARCHAR(16) NOT NULL  comment '状态',JOB_NAME VARCHAR(200) NULL  comment 'job名称',JOB_GROUP VARCHAR(200) NULL  comment 'job组',IS_NONCONCURRENT VARCHAR(1) NULL  comment '是否异步',REQUESTS_RECOVERY VARCHAR(1) NULL  comment '是否请求覆盖',PRIMARY KEY (SCHED_NAME,ENTRY_ID)
);
CREATE TABLE QRTZ_SCHEDULER_STATE
(SCHED_NAME VARCHAR(120) NOT NULL  comment '定时任务名称',INSTANCE_NAME VARCHAR(200) NOT NULL  comment '实例名称',LAST_CHECKIN_TIME BIGINT(13) NOT NULL  comment '最近检入时间',CHECKIN_INTERVAL BIGINT(13) NOT NULL  comment '检入间隔',PRIMARY KEY (SCHED_NAME,INSTANCE_NAME)
);
CREATE TABLE QRTZ_LOCKS
(SCHED_NAME VARCHAR(120) NOT NULL  comment '定时任务名称',LOCK_NAME  VARCHAR(40) NOT NULL  comment 'lock名称',PRIMARY KEY (SCHED_NAME,LOCK_NAME)
);
2. 制定一个定时任务

和上面一样的TestJob

java">@DisallowConcurrentExecution
public class TestJob implements Job {@Overridepublic void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {System.out.println("TestJob TEST开始");try {Thread.sleep(3000);} catch (InterruptedException e) {e.printStackTrace();}System.out.println("TestJob TEST结束");}
}
3. 写配置文件

MyJobFactory.java:

java">@Component
public class MyJobFactory extends SpringBeanJobFactory {@Resourceprivate AutowireCapableBeanFactory beanFactory;/*** 这里覆盖了super的createJobInstance方法,对其创建出来的类再进行autowire。*/@Overrideprotected Object createJobInstance(TriggerFiredBundle bundle) throws Exception {Object jobInstance = super.createJobInstance(bundle);beanFactory.autowireBean(jobInstance);return jobInstance;}
}

SchedulerConfig.java

java">@Configuration
public class SchedulerConfig {@Resourceprivate MyJobFactory myJobFactory;@Beanpublic SchedulerFactoryBean schedulerFactoryBean(@Qualifier("dataSource") DataSource dataSource) throws IOException {SchedulerFactoryBean factory = new SchedulerFactoryBean();factory.setDataSource(dataSource);factory.setJobFactory(myJobFactory);factory.setStartupDelay(2);return factory;}
}
4. 创建接收和相应实体类

接收实体类CronJobReq.java

java">public class CronJobReq {private String group;private String name;private String description;private String cronExpression;@Overridepublic String toString() {final StringBuffer sb = new StringBuffer("CronJobDto{");sb.append("cronExpression='").append(cronExpression).append('\'');sb.append(", group='").append(group).append('\'');sb.append(", name='").append(name).append('\'');sb.append(", description='").append(description).append('\'');sb.append('}');return sb.toString();}public String getGroup() {return group;}public void setGroup(String group) {this.group = group;}public String getCronExpression() {return cronExpression;}public void setCronExpression(String cronExpression) {this.cronExpression = cronExpression;}public String getDescription() {return description;}public void setDescription(String description) {this.description = description;}public String getName() {return name;}public void setName(String name) {this.name = name;}
}

响应实体类CronJobResp.java

java">@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class CronJobResp {private String group;private String name;private String description;private String state;private String cronExpression;@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")private Date nextFireTime;@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")private Date preFireTime;@Overridepublic String toString() {final StringBuffer sb = new StringBuffer("CronJobDto{");sb.append("cronExpression='").append(cronExpression).append('\'');sb.append(", group='").append(group).append('\'');sb.append(", name='").append(name).append('\'');sb.append(", description='").append(description).append('\'');sb.append(", state='").append(state).append('\'');sb.append(", nextFireTime=").append(nextFireTime);sb.append(", preFireTime=").append(preFireTime);sb.append('}');return sb.toString();}public String getGroup() {return group;}public void setGroup(String group) {this.group = group;}public String getCronExpression() {return cronExpression;}public void setCronExpression(String cronExpression) {this.cronExpression = cronExpression;}public String getDescription() {return description;}public void setDescription(String description) {this.description = description;}public String getName() {return name;}public void setName(String name) {this.name = name;}public Date getNextFireTime() {return nextFireTime;}public void setNextFireTime(Date nextFireTime) {this.nextFireTime = nextFireTime;}public Date getPreFireTime() {return preFireTime;}public void setPreFireTime(Date preFireTime) {this.preFireTime = preFireTime;}public String getState() {return state;}public void setState(String state) {this.state = state;}
}
5. 增删改查的controller层接口

任务和quartz通过接口来关联。CronJobReq类的name属性会告诉quartz操作哪个定时任务。

JobController.java:

java">@RestController
@RequestMapping(value = "/admin/job")
public class JobController {private static Logger LOG = LoggerFactory.getLogger(JobController.class);@Autowiredprivate SchedulerFactoryBean schedulerFactoryBean;@RequestMapping(value = "/run")public CommonResp<Object> run(@RequestBody CronJobReq cronJobReq) throws SchedulerException {String jobClassName = cronJobReq.getName();String jobGroupName = cronJobReq.getGroup();LOG.info("手动执行任务开始:{}, {}", jobClassName, jobGroupName);schedulerFactoryBean.getScheduler().triggerJob(JobKey.jobKey(jobClassName, jobGroupName));return new CommonResp<>();}@RequestMapping(value = "/add")public CommonResp add(@RequestBody CronJobReq cronJobReq) {String jobClassName = cronJobReq.getName();String jobGroupName = cronJobReq.getGroup();String cronExpression = cronJobReq.getCronExpression();String description = cronJobReq.getDescription();LOG.info("创建定时任务开始:{},{},{},{}", jobClassName, jobGroupName, cronExpression, description);CommonResp commonResp = new CommonResp();try {// 通过SchedulerFactory获取一个调度器实例Scheduler sched = schedulerFactoryBean.getScheduler();// 启动调度器sched.start();//构建job信息JobDetail jobDetail = JobBuilder.newJob((Class<? extends Job>) Class.forName(jobClassName)).withIdentity(jobClassName, jobGroupName).build();//表达式调度构建器(即任务执行的时间)CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule(cronExpression);//按新的cronExpression表达式构建一个新的triggerCronTrigger trigger = TriggerBuilder.newTrigger().withIdentity(jobClassName, jobGroupName).withDescription(description).withSchedule(scheduleBuilder).build();sched.scheduleJob(jobDetail, trigger);} catch (SchedulerException e) {LOG.error("创建定时任务失败:" + e);commonResp.setSuccess(false);commonResp.setMessage("创建定时任务失败:调度异常");} catch (ClassNotFoundException e) {LOG.error("创建定时任务失败:" + e);commonResp.setSuccess(false);commonResp.setMessage("创建定时任务失败:任务类不存在");}LOG.info("创建定时任务结束:{}", commonResp);return commonResp;}@RequestMapping(value = "/pause")public CommonResp pause(@RequestBody CronJobReq cronJobReq) {String jobClassName = cronJobReq.getName();String jobGroupName = cronJobReq.getGroup();LOG.info("暂停定时任务开始:{},{}", jobClassName, jobGroupName);CommonResp commonResp = new CommonResp();try {Scheduler sched = schedulerFactoryBean.getScheduler();sched.pauseJob(JobKey.jobKey(jobClassName, jobGroupName));} catch (SchedulerException e) {LOG.error("暂停定时任务失败:" + e);commonResp.setSuccess(false);commonResp.setMessage("暂停定时任务失败:调度异常");}LOG.info("暂停定时任务结束:{}", commonResp);return commonResp;}@RequestMapping(value = "/resume")public CommonResp resume(@RequestBody CronJobReq cronJobReq) {String jobClassName = cronJobReq.getName();String jobGroupName = cronJobReq.getGroup();LOG.info("重启定时任务开始:{},{}", jobClassName, jobGroupName);CommonResp commonResp = new CommonResp();try {Scheduler sched = schedulerFactoryBean.getScheduler();sched.resumeJob(JobKey.jobKey(jobClassName, jobGroupName));} catch (SchedulerException e) {LOG.error("重启定时任务失败:" + e);commonResp.setSuccess(false);commonResp.setMessage("重启定时任务失败:调度异常");}LOG.info("重启定时任务结束:{}", commonResp);return commonResp;}@RequestMapping(value = "/reschedule")public CommonResp reschedule(@RequestBody CronJobReq cronJobReq) {String jobClassName = cronJobReq.getName();String jobGroupName = cronJobReq.getGroup();String cronExpression = cronJobReq.getCronExpression();String description = cronJobReq.getDescription();LOG.info("更新定时任务开始:{},{},{},{}", jobClassName, jobGroupName, cronExpression, description);CommonResp commonResp = new CommonResp();try {Scheduler scheduler = schedulerFactoryBean.getScheduler();TriggerKey triggerKey = TriggerKey.triggerKey(jobClassName, jobGroupName);// 表达式调度构建器CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule(cronExpression);CronTriggerImpl trigger1 = (CronTriggerImpl) scheduler.getTrigger(triggerKey);trigger1.setStartTime(new Date()); // 重新设置开始时间CronTrigger trigger = trigger1;// 按新的cronExpression表达式重新构建triggertrigger = trigger.getTriggerBuilder().withIdentity(triggerKey).withDescription(description).withSchedule(scheduleBuilder).build();// 按新的trigger重新设置job执行scheduler.rescheduleJob(triggerKey, trigger);} catch (Exception e) {LOG.error("更新定时任务失败:" + e);commonResp.setSuccess(false);commonResp.setMessage("更新定时任务失败:调度异常");}LOG.info("更新定时任务结束:{}", commonResp);return commonResp;}@RequestMapping(value = "/delete")public CommonResp delete(@RequestBody CronJobReq cronJobReq) {String jobClassName = cronJobReq.getName();String jobGroupName = cronJobReq.getGroup();LOG.info("删除定时任务开始:{},{}", jobClassName, jobGroupName);CommonResp commonResp = new CommonResp();try {Scheduler scheduler = schedulerFactoryBean.getScheduler();scheduler.pauseTrigger(TriggerKey.triggerKey(jobClassName, jobGroupName));scheduler.unscheduleJob(TriggerKey.triggerKey(jobClassName, jobGroupName));scheduler.deleteJob(JobKey.jobKey(jobClassName, jobGroupName));} catch (SchedulerException e) {LOG.error("删除定时任务失败:" + e);commonResp.setSuccess(false);commonResp.setMessage("删除定时任务失败:调度异常");}LOG.info("删除定时任务结束:{}", commonResp);return commonResp;}@RequestMapping(value="/query")public CommonResp query() {LOG.info("查看所有定时任务开始");CommonResp commonResp = new CommonResp();List<CronJobResp> cronJobDtoList = new ArrayList();try {Scheduler scheduler = schedulerFactoryBean.getScheduler();for (String groupName : scheduler.getJobGroupNames()) {for (JobKey jobKey : scheduler.getJobKeys(GroupMatcher.jobGroupEquals(groupName))) {CronJobResp cronJobResp = new CronJobResp();cronJobResp.setName(jobKey.getName());cronJobResp.setGroup(jobKey.getGroup());//get job's triggerList<Trigger> triggers = (List<Trigger>) scheduler.getTriggersOfJob(jobKey);CronTrigger cronTrigger = (CronTrigger) triggers.get(0);cronJobResp.setNextFireTime(cronTrigger.getNextFireTime());cronJobResp.setPreFireTime(cronTrigger.getPreviousFireTime());cronJobResp.setCronExpression(cronTrigger.getCronExpression());cronJobResp.setDescription(cronTrigger.getDescription());Trigger.TriggerState triggerState = scheduler.getTriggerState(cronTrigger.getKey());cronJobResp.setState(triggerState.name());cronJobDtoList.add(cronJobResp);}}} catch (SchedulerException e) {LOG.error("查看定时任务失败:" + e);commonResp.setSuccess(false);commonResp.setMessage("查看定时任务失败:调度异常");}commonResp.setContent(cronJobDtoList);LOG.info("查看定时任务结束:{}", commonResp);return commonResp;}}
6. 编写接口测试代码

test.http:

POST http://localhost:8000/batch/admin/job/add
Content-Type: application/json{"name": "com.mystudy.train.batch.job.TestJob","jobGroupName": "default","cronExpression": "*/2 * * * * ?","desc": "test job"
}###GET http://localhost:8000/batch/admin/job/query###POST http://localhost:8000/batch/admin/job/pause
Content-Type: application/json{"name": "com.mystudy.train.batch.job.TestJob","jobGroupName": "default"
}###POST http://localhost:8000/batch/admin/job/resume
Content-Type: application/json{"name": "com.mystudy.train.batch.job.TestJob","jobGroupName": "default"
}###POST http://localhost:8000/batch/admin/job/reschedule
Content-Type: application/json{
"name": "com.mystudy.train.batch.job.TestJob",
"jobGroupName": "default",
"cronExpression": "*/5 * * * * ?",
"desc": "test job"
}###POST http://localhost:8000/batch/admin/job/delete
Content-Type: application/json{
"name": "com.mystudy.train.batch.job.TestJob",
"jobGroupName": "default"
}###

http://www.ppmy.cn/embedded/156741.html

相关文章

《Opencv》图像的透视变换--处理发票

目录 1. 引言 2. 准备工作 3. 图像预处理 4. 轮廓检测 5. 获取最大轮廓 6. 透视变换 7. 二值化处理 8. 结果展示 9、完整代码 10、结果展示 &#xff08;1&#xff09;、原图 &#xff08;2&#xff09;、处理后的图 11. 结论 在计算机视觉领域&#xff0c;透视变换…

c语言贪吃蛇(极简版,基本能玩)

c语言贪吃蛇 整体逻辑 界面绘制定义结构体以及结构体的初始化 2.1 一节变三节蛇的移动 3.1 监控键盘 3.2 蛇的移动食物 4.1 定义 4.2 初始化 4.3 食物的绘制食物的再生与身体增长、分数死亡与结束优化 7.1 getch()函数会返回两个数值&#xff0c;过滤第一个&#xff0c;留下第…

Vue3初学之Element Plus Dialog对话框,Message组件,MessageBox组件

Dialog的使用&#xff1a; 控制弹窗的显示和隐藏 <template><div><el-button click"dialogVisible true">打开弹窗</el-button><el-dialogv-model"dialogVisible"title"提示"width"30%":before-close&qu…

matlab绘图——彩色螺旋图

代码生成的图形是一个动态的彩色螺旋&#xff0c;展示了如何利用极坐标和颜色映射创建视觉吸引力强的图形。该图形可以用于数据可视化、艺术创作或数学演示&#xff0c;展示了 MATLAB 在图形处理方面的强大能力。通过调整 theta 和 r 的范围&#xff0c;可以创建出不同形状和复…

数据结构——实验八·学生管理系统

嗨~~欢迎来到Tubishu的博客&#x1f338;如果你也是一名在校大学生&#xff0c;正在寻找各种编程资源&#xff0c;那么你就来对地方啦&#x1f31f; Tubishu是一名计算机本科生&#xff0c;会不定期整理和分享学习中的优质资源&#xff0c;希望能为你的编程之路添砖加瓦⭐&…

RPC是什么?和HTTP区别?

RPC 是什么&#xff1f;HTTP 是什么&#xff1f; 作为一个程序员&#xff0c;假设我们需要从A电脑的进程发送一段数据到B电脑的进程&#xff0c;我们一般会在代码中使用 Socket 进行编程。 此时&#xff0c;可选性一般就是 TCP 和 UDP 二选一&#xff0c;由于 TCP 可靠、UDP 不…

GitCode 助力 AutoTable:共创 MyBatis 生态的自动表格管理新篇章

项目仓库https://gitcode.com/dromara/auto-table 解放双手&#xff0c;专注业务&#xff1a;MyBatis 生态的“自动表格”创新 AutoTable 是一款致力于为 MyBatis 生态赋予“自动表格”功能的创新插件。其核心理念是通过 Java 实体类自动生成和维护数据库的表结构&#xff0c…

汽车制造行业案例 | 发动机在制造品管理全解析(附解决方案模板)

目录 前言概述 业务背景 典型业务难题 智能制造解决思路 1.建立工序协同机制与动态调度系统 2.构建在制品全生命周期质量追溯平台 3.自定义搭建数字化智能生产计划 4.全方位设备预防性管理与应急管理 智能制造模板 前言概述 在制品管理是指对企业生产过程中处于加工、…