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>
  • 24
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值