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>
相关推荐
计算机学姐2 分钟前
基于Python的校园美食推荐系统【2026最新】
开发语言·vue.js·后端·python·mysql·django·推荐算法
q***48413 分钟前
十八,Spring Boot 整合 MyBatis-Plus 的详细配置
spring boot·后端·mybatis
悦悦子a啊12 分钟前
[Java]实验--编写TCP客户端程序
java·tcp/ip·php
linzeyang19 分钟前
Advent of Code 2025 挑战全手写代码 Day 5 - 餐厅
后端·python
yeshihouhou19 分钟前
springboot集成redis -RedisTemplate使用
spring boot·redis·后端
BBB努力学习程序设计21 分钟前
Java循环:让代码重复工作的"魔法"
java
Java水解22 分钟前
Spring Boot 中的 @ConditionalOnBean 注解详解
spring boot·后端
h***936628 分钟前
SpringBoot Test详解
spring boot·后端·log4j
掘金码甲哥40 分钟前
🎉刚入职的AIops菜鸡,应该知道gang-scheduling和binpack调度吗?
后端