public Result save(QuartzBean quartz) {
LOGGER.info("");
try {
if (quartz.getOldJobGroup() != null) {
JobKey key = new JobKey(quartz.getOldJobName(), quartz.getOldJobGroup());
scheduler.deleteJob(key);
}
Class cls = Class.forName(quartz.getJobClassName());
cls.newInstance();
JobDetail job = JobBuilder.newJob(cls).withIdentity(quartz.getJobName(),
quartz.getJobGroup())
.withDescription(quartz.getDescription()).build();
CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(quartz.getCronExpression());
Trigger trigger = TriggerBuilder.newTrigger().withIdentity("trigger" + quartz.getJobName(), quartz.getJobGroup())
.startNow().withSchedule(cronScheduleBuilder).build();
scheduler.scheduleJob(job, trigger);
} catch (Exception e) {
e.printStackTrace();
return Result.error();
}
return Result.ok();
}
Let me first declare that I am a beginner in quartz, but when integrating springboot, I found that it can be added to the database qrtz_cron_triggers and qrtz_job_details table by adjusting this new interface. I used druid to monitor and did not monitor the SQL statement. Is quartz operating the database itself? Is there a big god to help me