Quartz在spring boot项目中重启后不能继续执行问题

第一点:

CRON triggers

复制代码
  1. CronTrigger trigger = TriggerBuilder.newTrigger()

  2. .withIdentity(name, TRIGGER_GROUP)

  3. .withSchedule(

  4. CronScheduleBuilder.cronSchedule(time)

  5. .withMisfireHandlingInstructionDoNothing())

  6. .build();// 触发器名,触发器组,触发器时间设定

  

withMisfireHandlingInstructionDoNothing(所有的misfire不管,执行下一个周期的任务)

在quartz.properties配置文件中添加:

#这个时间大于10000(10秒)会导致MISFIRE_INSTRUCTION_DO_NOTHING不起作用。

org.quartz.jobStore.misfireThreshold = 1000

第二点:

配置文件中添加:jobStore

复制代码
org.quartz.scheduler.instanceName = DatartScheduleCluster

org.quartz.threadPool.threadCount = 10
org.quartz.threadPool.threadPriority = 5
org.quartz.jobStore.class = org.quartz.impl.jdbcjobstore.JobStoreTX
org.quartz.jobStore.driverDelegateClass = org.quartz.impl.jdbcjobstore.StdJDBCDelegate
org.quartz.jobStore.tablePrefix = QRTZ_
org.quartz.jobStore.dataSource = myDS
org.quartz.jobStore.useProperties = true
org.quartz.jobStore.misfireThreshold = 1000
org.quartz.jobStore.isClustered = true
org.quartz.jobStore.clusterCheckinInterval = 5000

org.quartz.dataSource.myDS.driver = com.mysql.jdbc.Driver
org.quartz.dataSource.myDS.URL = jdbc:mysql://172.29.60.145:3306:3306/datart?characterEncoding=utf-8&useSSL=false
# mysql8.0+ÒÔÉϰ汾ÅäÖÃ
# org.quartz.dataSource.myDS.URL=jdbc:mysql://localhost:3306/quartz?characterEncoding=utf-8&useSSL=false&serverTimezone = GMT
org.quartz.dataSource.myDS.user = root
org.quartz.dataSource.myDS.password = 123456
org.quartz.dataSource.myDS.maxConnections = 5
//这个一定要加
spring.quartz.job-store-type= jdbc

第三个pom中添加依赖:

复制代码
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-quartz</artifactId>
</dependency>

<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>8.0.29</version>
</dependency>
相关推荐
卷无止境7 小时前
Python能做嵌入式开发吗?一份写给动手派的生态与硬件全景图
后端·python
疯狂打码的少年11 小时前
【数据库技术】关系模型基本概念(关系/属性/元组/键)
java·服务器·数据库·笔记
Sherotree13 小时前
Google Antigravity——Agent 被提到主界面
前端·ide·后端·edge浏览器
Mr数据杨13 小时前
【Codex】用学生入学评估模块建立新生能力画像
android·java·javascript·django·codex·项目开发
2601_9620562313 小时前
Spring Boot 入门 与 无法解析符号 springframework 的解决
java·spring boot·后端
Thomas214314 小时前
Java scala 数组 链表
java·链表·scala
亚历克斯神14 小时前
低代码与 AI 的融合趋势——从可视化搭建到自然语言生成应用
java·spring·微服务
你驴我14 小时前
WhatsApp 多账号场景下的会话归档与历史消息检索优化实践
后端·python
学长毕业设计14 小时前
基于SpringBoot的瑜伽馆网站的设计与实现(源码+文档+讲解视频)
java·spring boot·后端
一嘴一个橘子14 小时前
nginx 常用命令(在 nginx 目录下执行)
java