无法在 springboot 应用程序中检索石英作业

Unable to retrieve quartz job in springboot app

我可以在 spring 中创建 quartz 作业,但这是我唯一能做的事情。作业没有触发,我可以检查作业是否存在但无法检索它。

我正在使用 springboot 2.6.6。我的配置如下所示:

spring:
  ################################
  # application properties
  ################################
  application:
    name: job-manager
  ################################
  # postgress database
  ################################
  datasource:
    url: ${db.url}
    username: ${db.username}
    password: ${db.password}
  jpa:
    properties:
      hibernate:
        dialect: org.hibernate.dialect.PostgreSQLDialect
        ddl-auto: validate
        #format_sql: true
    show-sql: true
    ################################
    # Quartz configuration
    ################################
  quartz:
    auto-startup: false
    job-store-type: jdbc 
    wait-for-jobs-to-complete-on-shutdown: true
    jdbc.initialize-schema: never
    properties:
      org.quartz.threadPool.threadCount: 5   # each thread runs a concurrent job
org:
  quartz:
    jobStore.driverDelegateClass: org.quartz.impl.jdbcjobstore.PostgreSQLDelegate

我可以创建新作业及其触发器,但触发器从未触发。我也可以毫无问题地执行以下命令,它 returns true:

scheduler.checkExists(new JobKey(jobName, jobGroupName));

以上代码段 returns 正确。但是当我尝试执行

jobDetail = scheduler.getJobDetail(new JobKey(jobName, jobGroupName));

我收到以下错误:

org.quartz.JobPersistenceException: Couldn't retrieve job: Bad value for type long : \xaced0005737200156f72672e71756172747a2e4a6f62446174614d61709fb083e8bfa9b0cb020000787200266f72672e71756172747a2e7574696c732e537472696e674b65794469727479466c61674d61708208e8c3fbc55d280200015a0013616c6c6f77735472616e7369656e74446174617872001d6f72672e71756172747a2e7574696c732e4469727479466c61674d617013e62ead28760ace0200025a000564697274794c00036d617074000f4c6a6176612f7574696c2f4d61703b787000737200116a6176612e7574696c2e486173684d61700507dac1c31660d103000246000a6c6f6164466163746f724900097468726573686f6c6478703f40000000000010770800000010000000007800
    at org.quartz.impl.jdbcjobstore.JobStoreSupport.retrieveJob(JobStoreSupport.java:1401) ~[quartz-2.3.2.jar:na]
    at org.quartz.impl.jdbcjobstore.JobStoreSupport.execute(JobStoreSupport.java:1382) ~[quartz-2.3.2.jar:na]

嵌套异常是

Caused by: org.postgresql.util.PSQLException: Bad value for type long : \xaced0005737200156f72672e71756172747a2e4a6f62446174614d61709fb083e8bfa9b0cb020000787200266f72672e71756172747a2e7574696c732e537472696e674b65794469727479466c61674d61708208e8c3fbc55d280200015a0013616c6c6f77735472616e7369656e74446174617872001d6f72672e71756172747a2e7574696c732e4469727479466c61674d617013e62ead28760ace0200025a000564697274794c00036d617074000f4c6a6176612f7574696c2f4d61703b787000737200116a6176612e7574696c2e486173684d61700507dac1c31660d103000246000a6c6f6164466163746f724900097468726573686f6c6478703f40000000000010770800000010000000007800

任何想法。我找到了一个类似的 post 没有答案。任何帮助将不胜感激。

问题是配置“org.quartz.jobStore.driverDelegateClass”没有正确选择“org.quartz.impl.jdbcjobstore.PostgreSQLDelegate”。 根据您的例外情况,Delegate class 仍然是 'org.quartz.impl.jdbcjobstore.StdJDBCDelegate'

的默认实现

yaml 配置似乎有误,参考这里:Spring Boot Quartz Scheduler Configuration