In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
The following together to understand how to achieve SpringBoot+Quartz+Maven+MySql dynamic timing task, I believe that we will benefit a lot after reading, the text in the essence is not much, hope that how to achieve SpringBoot+Quartz+Maven+MySql dynamic timing task this short content is what you want.
Packages that need to be imported for 1.Quartz, Maven configuration
Org.quartz-scheduler
Quartz
2.2.3
Org.quartz-scheduler
Quartz-jobs
2.2.3
Tables that 2.Quartz needs to use
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
#-Store the details of each configured Job
CREATE TABLE qrtz_job_details (
SCHED_NAME VARCHAR (120) NOT NULL
JOB_NAME VARCHAR (200) NOT NULL
JOB_GROUP VARCHAR (200) NOT NULL
DESCRIPTION VARCHAR (250) NULL
JOB_CLASS_NAME VARCHAR (250) NOT NULL
IS_DURABLE VARCHAR (1) NOT NULL
IS_NONCONCURRENT VARCHAR (1) NOT NULL
IS_UPDATE_DATA VARCHAR (1) NOT NULL
REQUESTS_RECOVERY VARCHAR (1) NOT NULL
JOB_DATA BLOB NULL
PRIMARY KEY (SCHED_NAME,JOB_NAME,JOB_GROUP)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
#-Storage information of configured Trigger
CREATE TABLE qrtz_triggers (
SCHED_NAME VARCHAR (120) NOT NULL
TRIGGER_NAME VARCHAR (200) NOT NULL
TRIGGER_GROUP VARCHAR (200) NOT NULL
JOB_NAME VARCHAR (200) NOT NULL
JOB_GROUP VARCHAR (200) NOT NULL
DESCRIPTION VARCHAR (250) NULL
NEXT_FIRE_TIME BIGINT (13) NULL
PREV_FIRE_TIME BIGINT (13) NULL
PRIORITY INTEGER NULL
TRIGGER_STATE VARCHAR (16) NOT NULL
TRIGGER_TYPE VARCHAR (8) NOT NULL
START_TIME BIGINT (13) NOT NULL
END_TIME BIGINT (13) NULL
CALENDAR_NAME VARCHAR (200) NULL
MISFIRE_INSTR SMALLINT (2) NULL
JOB_DATA BLOB NULL
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)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
#-Storage simple Trigger, including the number of repeats, intervals, and the number of times touched
CREATE TABLE qrtz_simple_triggers (
SCHED_NAME VARCHAR (120) NOT NULL
TRIGGER_NAME VARCHAR (200) NOT NULL
TRIGGER_GROUP VARCHAR (200) NOT NULL
REPEAT_COUNT BIGINT (7) NOT NULL
REPEAT_INTERVAL BIGINT (12) NOT NULL
TIMES_TRIGGERED BIGINT (10) NOT NULL
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)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
#-Store Cron Trigger, including Cron expressions and time zone information
CREATE TABLE qrtz_cron_triggers (
SCHED_NAME VARCHAR (120) NOT NULL
TRIGGER_NAME VARCHAR (200) NOT NULL
TRIGGER_GROUP VARCHAR (200) NOT NULL
CRON_EXPRESSION VARCHAR (120) NOT NULL
TIME_ZONE_ID VARCHAR (80)
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)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
#-Storage simple Trigger, including the number of repeats, intervals, and the number of times touched
CREATE TABLE qrtz_simprop_triggers (
SCHED_NAME VARCHAR (120) NOT NULL
TRIGGER_NAME VARCHAR (200) NOT NULL
TRIGGER_GROUP VARCHAR (200) NOT NULL
STR_PROP_1 VARCHAR (512) NULL
STR_PROP_2 VARCHAR (512) NULL
STR_PROP_3 VARCHAR (512) NULL
INT_PROP_1 INT NULL
INT_PROP_2 INT NULL
LONG_PROP_1 BIGINT NULL
LONG_PROP_2 BIGINT NULL
DEC_PROP_1 NUMERIC (13pr 4) NULL
DEC_PROP_2 NUMERIC (13pr 4) NULL
BOOL_PROP_1 VARCHAR (1) NULL
BOOL_PROP_2 VARCHAR (1) NULL
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)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
#-Trigger is stored as a Blob type
#-(used when Quartz users create their own custom Trigger types with JDBC, and JobStore does not know how to store instances)
CREATE TABLE qrtz_blob_triggers (
SCHED_NAME VARCHAR (120) NOT NULL
TRIGGER_NAME VARCHAR (200) NOT NULL
TRIGGER_GROUP VARCHAR (200) NOT NULL
BLOB_DATA BLOB NULL
PRIMARY KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)
INDEX (SCHED_NAME,TRIGGER_NAME, TRIGGER_GROUP)
FOREIGN KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)
REFERENCES qrtz_triggers (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
#-storing Calendar information of Quartz in Blob type
CREATE TABLE qrtz_calendars (
SCHED_NAME VARCHAR (120) NOT NULL
CALENDAR_NAME VARCHAR (200) NOT NULL
CALENDAR BLOB NOT NULL
PRIMARY KEY (SCHED_NAME,CALENDAR_NAME)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
#-storing information about paused Trigger groups
CREATE TABLE qrtz_paused_trigger_grps (
SCHED_NAME VARCHAR (120) NOT NULL
TRIGGER_GROUP VARCHAR (200) NOT NULL
PRIMARY KEY (SCHED_NAME,TRIGGER_GROUP)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
#-Store status information related to triggered Trigger and execution information of associated Job
CREATE TABLE qrtz_fired_triggers (
SCHED_NAME VARCHAR (120) NOT NULL
ENTRY_ID VARCHAR (95) NOT NULL
TRIGGER_NAME VARCHAR (200) NOT NULL
TRIGGER_GROUP VARCHAR (200) NOT NULL
INSTANCE_NAME VARCHAR (200) NOT NULL
FIRED_TIME BIGINT (13) NOT NULL
SCHED_TIME BIGINT (13) NOT NULL
PRIORITY INTEGER NOT NULL
STATE VARCHAR (16) NOT NULL
JOB_NAME VARCHAR (200) NULL
JOB_GROUP VARCHAR (200) NULL
IS_NONCONCURRENT VARCHAR (1) NULL
REQUESTS_RECOVERY VARCHAR (1) NULL
PRIMARY KEY (SCHED_NAME,ENTRY_ID)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
#-Store a small amount of status information about Scheduler and other Scheduler instances (if used in a cluster)
CREATE TABLE qrtz_scheduler_state (
SCHED_NAME VARCHAR (120) NOT NULL
INSTANCE_NAME VARCHAR (200) NOT NULL
LAST_CHECKIN_TIME BIGINT (13) NOT NULL
CHECKIN_INTERVAL BIGINT (13) NOT NULL
PRIMARY KEY (SCHED_NAME,INSTANCE_NAME)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
#-storing information about pessimistic locks of the program (if pessimistic locks are used)
CREATE TABLE qrtz_locks (
SCHED_NAME VARCHAR (120) NOT NULL
LOCK_NAME VARCHAR (40) NOT NULL
PRIMARY KEY (SCHED_NAME,LOCK_NAME)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
CREATE INDEX IDX_QRTZ_J_REQ_RECOVERY ON qrtz_job_details (SCHED_NAME,REQUESTS_RECOVERY)
CREATE INDEX IDX_QRTZ_J_GRP ON qrtz_job_details (SCHED_NAME,JOB_GROUP)
CREATE INDEX IDX_QRTZ_T_J ON qrtz_triggers (SCHED_NAME,JOB_NAME,JOB_GROUP)
CREATE INDEX IDX_QRTZ_T_JG ON qrtz_triggers (SCHED_NAME,JOB_GROUP)
CREATE INDEX IDX_QRTZ_T_C ON qrtz_triggers (SCHED_NAME,CALENDAR_NAME)
CREATE INDEX IDX_QRTZ_T_G ON qrtz_triggers (SCHED_NAME,TRIGGER_GROUP)
CREATE INDEX IDX_QRTZ_T_STATE ON qrtz_triggers (SCHED_NAME,TRIGGER_STATE)
CREATE INDEX IDX_QRTZ_T_N_STATE ON qrtz_triggers (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP,TRIGGER_STATE)
CREATE INDEX IDX_QRTZ_T_N_G_STATE ON qrtz_triggers (SCHED_NAME,TRIGGER_GROUP,TRIGGER_STATE)
CREATE INDEX IDX_QRTZ_T_NEXT_FIRE_TIME ON qrtz_triggers (SCHED_NAME,NEXT_FIRE_TIME)
CREATE INDEX IDX_QRTZ_T_NFT_ST ON qrtz_triggers (SCHED_NAME,TRIGGER_STATE,NEXT_FIRE_TIME)
CREATE INDEX IDX_QRTZ_T_NFT_MISFIRE ON qrtz_triggers (SCHED_NAME,MISFIRE_INSTR,NEXT_FIRE_TIME)
CREATE INDEX IDX_QRTZ_T_NFT_ST_MISFIRE ON qrtz_triggers (SCHED_NAME,MISFIRE_INSTR,NEXT_FIRE_TIME,TRIGGER_STATE)
CREATE INDEX IDX_QRTZ_T_NFT_ST_MISFIRE_GRP ON qrtz_triggers (SCHED_NAME,MISFIRE_INSTR,NEXT_FIRE_TIME,TRIGGER_GROUP,TRIGGER_STATE)
CREATE INDEX IDX_QRTZ_FT_TRIG_INST_NAME ON qrtz_fired_triggers (SCHED_NAME,INSTANCE_NAME)
CREATE INDEX IDX_QRTZ_FT_INST_JOB_REQ_RCVRY ON qrtz_fired_triggers (SCHED_NAME,INSTANCE_NAME,REQUESTS_RECOVERY)
CREATE INDEX IDX_QRTZ_FT_J_G ON qrtz_fired_triggers (SCHED_NAME,JOB_NAME,JOB_GROUP)
CREATE INDEX IDX_QRTZ_FT_JG ON qrtz_fired_triggers (SCHED_NAME,JOB_GROUP)
CREATE INDEX IDX_QRTZ_FT_T_G ON qrtz_fired_triggers (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)
CREATE INDEX IDX_QRTZ_FT_TG ON qrtz_fired_triggers (SCHED_NAME,TRIGGER_GROUP)
Commit
Configuration required for 3.Quartz (quartz.properties)
# quartz cluster configuration
# =
# Configure Main Scheduler Properties Scheduler Properties
# =
# scheduling identity name every instance in the cluster must use the same name
Org.quartz.scheduler.instanceName=DefaultQuartzScheduler
# ID set to automatically get each must be different
Org.quartz.scheduler.instanceid=AUTO
# =
# Configure ThreadPool
# =
# implementation class of thread pool (generally SimpleThreadPool can meet the needs of almost all users)
Org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
# specify the number of threads, at least 1 (no default) (generally set to 1-100 direct integers are appropriate)
Org.quartz.threadPool.threadCount = 25
# set thread priority (maximum is java.lang.Thread.MAX_PRIORITY 10, minimum is Thread.MIN_PRIORITY 1, default is 5)
Org.quartz.threadPool.threadPriority = 5
# =
# Configure JobStore
# =
# default value of information preservation time is 60 seconds
Org.quartz.jobStore.misfireThreshold = 60000
# data is saved for database persistence
Org.quartz.jobStore.class = org.quartz.impl.jdbcjobstore.JobStoreTX
# Database proxy class, generally org.quartz.impl.jdbcjobstore.StdJDBCDelegate can satisfy most databases
Org.quartz.jobStore.driverDelegateClass = org.quartz.impl.jdbcjobstore.StdJDBCDelegate
# whether all JobDataMaps are of String type
Org.quartz.jobStore.useProperties = false
# pick a database alias at will
Org.quartz.jobStore.dataSource = myDS
# prefix of table, default QRTZ_
Org.quartz.jobStore.tablePrefix = QRTZ_
# whether to join the cluster
Org.quartz.jobStore.isClustered = true
# check interval for scheduling instance failure
Org.quartz.jobStore.clusterCheckinInterval = 20000
# =
# Configure Datasources
# =
# Database engine
Org.quartz.dataSource.myDS.driver = com.mysql.jdbc.Driver
# Database connection
Org.quartz.dataSource.myDS.URL = jdbc:mysql://localhost:3306/testdb?characterEncoding=utf8&allowMultiQueries=true&useSSL=false&autoReconnect=true
# Database users
Org.quartz.dataSource.myDS.user = root
# Database password
Org.quartz.dataSource.myDS.password = root
# allow maximum connection
Org.quartz.dataSource.myDS.maxConnections = 5
# verify query sql, which can be left unset
Org.quartz.dataSource.myDS.validationQuery=select 0 from dual
4.Quartz Task Factory Class (TaskJobFactory)
@ Component
Public class TaskJobFactory extends AdaptableJobFactory {
@ Autowired
AutowireCapableBeanFactory capableBeanFactory
@ Override
Protected Object createJobInstance (TriggerFiredBundle bundle) throws Exception {
/ / call the method of the parent class
Object jobInstance = super.createJobInstance (bundle)
/ / perform injection
CapableBeanFactory.autowireBean (jobInstance)
Return jobInstance
}
}
5.Quartz configuration Class (QuartzConfigurer)
@ Configuration
Public class QuartzConfigurer {
@ Autowired
DataSource dataSource
@ Autowired
TaskJobFactory jobFactory
@ Bean (name = "SchedulerFactory")
Public SchedulerFactoryBean schedulerFactoryBean () throws IOException {
/ / get configuration properties
PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean ()
PropertiesFactoryBean.setLocation (new ClassPathResource ("/ quartz.properties"))
/ / initialize the object after the attributes in quartz.properties are read and injected
PropertiesFactoryBean.afterPropertiesSet ()
/ / create a SchedulerFactoryBean
SchedulerFactoryBean factory = new SchedulerFactoryBean ()
Factory.setQuartzProperties (propertiesFactoryBean.getObject ())
Factory.setJobFactory (jobFactory)
Return factory
}
/ *
* obtain the instance of Scheduler through SchedulerFactoryBean
* /
@ Bean (name = "scheduler")
Public Scheduler scheduler () throws IOException {
Return schedulerFactoryBean () .getScheduler ()
}
}
6.Quartz operation class (QuartzJobManager)
@ Component
Public class QuartzJobManager {
Private static final Logger logger = LoggerFactory.getLogger (QuartzJobManager.class)
Private static QuartzJobManager jobUtil
@ Autowired
Private Scheduler scheduler
Public QuartzJobManager () {
Logger.info ("init jobUtil")
JobUtil = this
}
Public static QuartzJobManager getInstance () {
Logger.info ("return JobCreateUtil")
Return QuartzJobManager.jobUtil
}
/ * *
* create job
*
* @ param clazz task class
* @ param jobName task name
* @ param jobGroupName task name of the group
* @ param cronExpression cron expression
* /
Public void addJob (Class clazz, String jobName, String jobGroupName, String cronExpression) {
AddJob (clazz, jobName, jobGroupName, cronExpression, null)
}
/ * *
* create a job and pass parameters
*
* @ param clazz task class
* @ param jobName task name
* @ param jobGroupName task name of the group
* @ param cronExpression cron expression
* @ param argMap map form parameter
* /
Public void addJob (Class clazz, String jobName, String jobGroupName, String cronExpression, Map argMap) {
Try {
/ / start the scheduler
Scheduler.start ()
/ / build job information
JobDetail jobDetail = JobBuilder.newJob (Job) clazz.newInstance ()) .getClass ()) .withidentity (jobName, jobGroupName) .build ()
/ / expression scheduling builder (that is, the time when the task is executed)
CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule (cronExpression)
/ / build a new cronExpression according to the new trigger expression
CronTrigger trigger = TriggerBuilder.newTrigger () .withIdentity (jobName, jobGroupName) .withschedule (scheduleBuilder) .build ()
/ / obtain JobDataMap and write data
If (argMap! = null) {
Trigger.getJobDataMap () putAll (argMap)
}
Scheduler.scheduleJob (jobDetail, trigger)
} catch (Exception e) {
E.printStackTrace ()
}
}
/ * *
* pause job
*
* @ param jobName task name
* @ param jobGroupName task name of the group
* /
Public void pauseJob (String jobName, String jobGroupName) {
Try {
Scheduler.pauseJob (JobKey.jobKey (jobName, jobGroupName))
} catch (SchedulerException e) {
E.printStackTrace ()
}
}
/ * *
* restore job
*
* @ param jobName task name
* @ param jobGroupName task name of the group
* /
Public void resumeJob (String jobName, String jobGroupName) {
Try {
Scheduler.resumeJob (JobKey.jobKey (jobName, jobGroupName))
} catch (SchedulerException e) {
E.printStackTrace ()
}
}
/ * *
* job updates, update frequency only
*
* @ param jobName task name
* @ param jobGroupName task name of the group
* @ param cronExpression cron expression
* /
Public void updateJob (String jobName, String jobGroupName, String cronExpression) {
UpdateJob (jobName, jobGroupName, cronExpression, null)
}
/ * *
* job updates, update frequency and parameters
*
* @ param jobName task name
* @ param jobGroupName task name of the group
* @ param cronExpression cron expression
* @ param argMap parameter
* /
Public void updateJob (String jobName, String jobGroupName, String cronExpression, Map argMap) {
Try {
TriggerKey triggerKey = TriggerKey.triggerKey (jobName, jobGroupName)
/ / expression scheduling builder
CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule (cronExpression)
CronTrigger trigger = (CronTrigger) scheduler.getTrigger (triggerKey)
/ / rebuild trigger with a new cronExpression expression
Trigger = trigger.getTriggerBuilder () .withIdentity (triggerKey) .withschedule (scheduleBuilder) .build ()
/ / modify map
If (argMap! = null) {
Trigger.getJobDataMap () putAll (argMap)
} Wuxi × × Hospital http://www.bhnkyixue.com/
/ / reset job execution by the new trigger
Scheduler.rescheduleJob (triggerKey, trigger)
} catch (Exception e) {
E.printStackTrace ()
}
}
/ * *
* job update, only update update parameters
*
* @ param jobName task name
* @ param jobGroupName task name of the group
* @ param argMap parameter
* /
Public void updateJob (String jobName, String jobGroupName, Map argMap) {
Try {
TriggerKey triggerKey = TriggerKey.triggerKey (jobName, jobGroupName)
CronTrigger trigger = (CronTrigger) scheduler.getTrigger (triggerKey)
/ / modify map
Trigger.getJobDataMap () putAll (argMap)
/ / reset job execution by the new trigger
Scheduler.rescheduleJob (triggerKey, trigger)
} catch (Exception e) {
E.printStackTrace ()
}
}
/ * *
* job deletion
*
* @ param jobName task name
* @ param jobGroupName task name of the group
* /
Public void deleteJob (String jobName, String jobGroupName) {
Try {
Scheduler.pauseTrigger (TriggerKey.triggerKey (jobName, jobGroupName))
Scheduler.unscheduleJob (TriggerKey.triggerKey (jobName, jobGroupName))
Scheduler.deleteJob (JobKey.jobKey (jobName, jobGroupName))
} catch (Exception e) {
E.printStackTrace ()
}
}
/ * *
* start all scheduled tasks
* /
Public void startAllJobs () {
Try {
Scheduler.start ()
} catch (Exception e) {
Throw new RuntimeException (e)
}
}
/ * *
* turn off all scheduled tasks
* /
Public void shutdownAllJobs () {
Try {
If (! scheduler.isShutdown ()) {
Scheduler.shutdown ()
}
} catch (Exception e) {
Throw new RuntimeException (e)
}
}
/ * *
* get all task lists
*
* @ return
* /
Public List > getAllJob () {
GroupMatcher matcher = GroupMatcher.anyJobGroup ()
List > jobList = new ArrayList ()
Set jobKeys = null
Try {
JobKeys = scheduler.getJobKeys (matcher)
For (JobKey jobKey: jobKeys) {
List triggers = scheduler.getTriggersOfJob (jobKey)
For (Trigger trigger: triggers) {
Map job = new HashMap ()
Job.put ("jobName", jobKey.getName ())
Job.put ("jobGroupName", jobKey.getGroup ())
Job.put ("trigger", trigger.getKey ())
Trigger.TriggerState triggerState = scheduler.getTriggerState (trigger.getKey ())
Job.put ("jobStatus", triggerState.name ())
If (trigger instanceof CronTrigger) {
CronTrigger cronTrigger = (CronTrigger) trigger
String cronExpression = cronTrigger.getCron_Expression ()
Job.put ("cronExpression", cronExpression)
}
JobList.add (job)
}
}
} catch (SchedulerException e) {
E.printStackTrace ()
}
Return jobList
}
}
7. Test class (TestQuartz)
@ Component
Public class TestQuartz implements Job {
@ Override
Public void execute (JobExecutionContext context) throws JobExecutionException {
/ / get the task name
String taskName = context.getJobDetail (). GetKey (). GetName ()
/ / handle the business after performing the task
}
}
8. Test class (JobController)
@ Controller
@ RequestMapping ("/ job")
Public class JobController {
@ Autowired
QuartzJobManager quartzJobManager
@ GetMapping ("/ add")
Public void add (HttpServletRequest request) {
/ / Task name
String name = request.getParameter ("name")
/ / Task Group name
String groupName = "task"
/ / cron expression
String cron = "0 0max 1 *?"
/ / parameters to be carried to the task
Map map = new HashMap ()
Map.put ("name", "Zhang San")
Map.put ("sex", "0")
QuartzJobManager.addJob (TestQuartz.class, name, groupName, cron, map)
}
@ GetMapping ("/ del")
Public void del (HttpServletRequest request) {
String name = request.getParameter ("name")
String groupName = "task"
QuartzJobManager.deleteJob (name, groupName)
}
}
This is all the source code needed for a Quartz dynamic task, only 2 are written in the test, and the rest can be tested by yourself. A simple Quartz test case is built, and you can also expand it directly based on the business scenario of the project.
After reading this article on how to achieve SpringBoot+Quartz+Maven+MySql dynamic timing tasks, many readers will want to know more about it. If you need more industry information, you can follow our industry information section.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.