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

news/2025/1/24 17:06:24/

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/news/1565827.html

相关文章

网络安全大模型和人工智能场景及应用理解

本文通过通俗易懂的方式的进行阐述&#xff0c;大家读完觉得有帮助记得及时关注和点赞&#xff01;&#xff01;&#xff01; 一、网络安全大模型的概述 网络安全大模型是一种用于识别和应对各种网络安全威胁的模型。它通过分析网络数据包、网络行为等信息&#xff0c;识别潜在…

【柱状图】——18

&#x1f31f; 解锁数据可视化的魔法钥匙 —— pyecharts实战指南 &#x1f31f; 在这个数据为王的时代&#xff0c;每一次点击、每一次交易、每一份报告背后都隐藏着无尽的故事与洞察。但你是否曾苦恼于如何将这些冰冷的数据转化为直观、吸引人的视觉盛宴&#xff1f; &…

介绍用于机器学习的 Fashion-MNIST 数据集

介绍用于机器学习的 Fashion-MNIST 数据集 为什么要研究数据集&#xff1f; 让我们首先思考一下为什么要花时间研究数据集的问题。数据是深度学习的主要成分&#xff0c;虽然作为神经网络程序员的任务是让我们的神经网络从我们的数据中学习&#xff0c;但我们仍然有责任了解我…

SSM开发(二) MyBatis两种SQL配置方式及其对比

目录 一、MyBatis两种SQL配置方式 二、使用XML映射文件配置SQL语句 三、使用注解配置SQL语句 四、两种方式对比 总结 1、注解 2、XML配置 五、MyBatis多数据源的两种配置方式 参考 一、MyBatis两种SQL配置方式 MyBatis 提供了两种方式来配置SQL语句&#xff1a;注解&a…

Mysql面试题----什么是垂直分表、垂直分库、水平分库、水平分表

垂直分表 概念&#xff1a;将一个表按照字段进行拆分&#xff0c;把经常一起使用的字段放在一个表中&#xff0c;不常用的字段或者大字段&#xff08;如文本、图片链接等&#xff09;放到另一个表中。这些表拥有相同的主键&#xff0c;通过主键关联数据。使用场景&#xff1a;…

深入MapReduce——计算模型设计

引入 通过引入篇&#xff0c;我们可以总结&#xff0c;MapReduce针对海量数据计算核心痛点的解法如下&#xff1a; 统一编程模型&#xff0c;降低用户使用门槛分而治之&#xff0c;利用了并行处理提高计算效率移动计算&#xff0c;减少硬件瓶颈的限制 优秀的设计&#xff0c…

mybatis(57/134)

今天没什么想法&#xff0c;搭了个转账平台&#xff0c;加深了点之前javaweb的mvc架构的印象&#xff0c;还有异常的抛出处理等

一键视频转文字/音频转文字,浏览器右键提取B站视频文案,不限时长免费无限次可用

上篇文章阿虚分享了自己的「短视频」笔记方案 短视频文件小&#xff0c;易存储&#xff0c;所以阿虚建议是直接将原视频插入到笔记当中 而长视频文件大&#xff0c;很难像短视频一样操作。阿虚之前的建议是提取重要部分视频转长截图&#xff0c;或者视频转GIF 但上述方案仔细…