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中添加依赖:


    org.springframework.boot
    spring-boot-starter-quartz



    mysql
    mysql-connector-java
    8.0.29

你可能感兴趣的:(spring,boot,后端,java)