【问题标题】:How to set the database schema for the Quartz scheduler with Spring Boot and Flyway?如何使用 Spring Boot 和 Flyway 为 Quartz 调度程序设置数据库模式?
【发布时间】:2021-01-10 16:20:42
【问题描述】:

我有一个 Spring Boot 应用程序,它使用 Quartz 调度程序和 PostGreSQL 数据库作为存储。我正在将其从使用public 架构的自己的数据库运行迁移到针对每个应用程序一个架构的共享数据库运行。架构由 管理。

在测试期间(使用)应用程序启动失败

Caused by: org.postgresql.util.PSQLException: ERROR: relation "qrtz_locks" does not exist
  Position: 15

尽管 flyway 之前已在架构 app_test_hub_scheduler_v0 中创建了该表。

配置是

spring:
  jpa.properties:
    hibernate.default_schema: app_test_hub_scheduler_v0
  flyway:
    enabled: true
    schemas: app_test_hub_scheduler_v0
  jpa:
    properties:
      hibernate:
        default_schema: app_test_hub_scheduler_v0
  quartz:
    jdbc:
      schema: app_test_hub_scheduler_v0
jdbcUrlParams: ?currentSchema=app_test_hub_scheduler_v0

石英的属性是

org.quartz.scheduler.instanceName=test-hub-scheduler
org.quartz.scheduler.instanceId=AUTO
org.quartz.threadPool.class=org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount=50
org.quartz.jobStore.misfireThreshold=60000
org.quartz.jobStore.class=org.quartz.impl.jdbcjobstore.JobStoreTX
org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.PostgreSQLDelegate
org.quartz.jobStore.useProperties=true
org.quartz.jobStore.dataSource=myDS
org.quartz.jobStore.tablePrefix=qrtz_
org.quartz.jobStore.isClustered=false

石英似乎没有获得模式名称。如何设置?

【问题讨论】:

  • 您能否检查并确认您的架构中是否存在 LOCK 表。我假设由于您通过 flyway 管理石英表,该表可能缺少您在quartz.properties tablePrefix=qrtz_ 中声明的前缀
  • @user06062019 飞路:Executing SQL: CREATE TABLE IF NOT EXISTS qrtz_locks
  • 您可以尝试在表前缀中设置 schema_name 并尝试一下
  • @user06062019 是的,可行:org.quartz.jobStore.tablePrefix=app_test_hub_scheduler_v0.qrtz_。请给出答案。

标签: flyway testcontainers spring spring-boot quartz-scheduler database-schema flyway


【解决方案1】:

如果在 quartz.properties 中声明了以下属性,则 Quartz 调度程序可以考虑 schema_name。例如

org.quartz.jobStore.tablePrefix=app_test_hub_scheduler_v0.qrtz_

这里

app_test_hub_scheduler_v0 = is schema name and
qrtz_= is quartz table prefix

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-07-24
    • 2019-02-17
    • 1970-01-01
    • 1970-01-01
    • 2012-03-17
    • 1970-01-01
    • 2020-07-23
    • 2020-07-06
    相关资源
    最近更新 更多