2016-12-26 106 views
0

最近我尝试配置我的Grails应用程序与石英调度程序一起使用。不幸的是,我配置JDBC作业存储失败。石英插件似乎忽略quartz.properties文件,其中表前缀被定义为Z_STAFF_SCHEDULER。应用程序启动失败,出现异常:如何在grails 3中配置quartz插件?

引起:org.springframework.scheduling.SchedulingException:可能 无法启动Quartz Scheduler;嵌套的异常是 org.quartz.SchedulerConfigException:在作业 恢复期间发生故障。 [查看嵌套异常: org.quartz.impl.jdbcjobstore.LockException:获取db行失败 锁:表'testing.qrtz_locks'不存在[请参阅嵌套异常: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException :表 'testing.qrtz_locks' 不存在]

这里是application.groovy相关代码:

quartz { 
    autoStartup = true 
    jdbcStore = true 
    waitForJobsToCompleteOnShutdown = true 
    exposeSchedulerInRepository = false 

    props { 
     scheduler.skipUpdateCheck = true 
    } 

} 

environments { 
    test { 
     quartz { 
      jdbcStore = false 
      autoStartup = false 
     } 
    } 
} 


grails.config.locations = ["classpath:conf/quartz.properties"] 

,这是我在quartz.properties配置:

#============================================================================ 
# Configure Main Scheduler Properties 
#============================================================================ 

org.quartz.scheduler.instanceName = StaffScheduler 
org.quartz.scheduler.instanceId = AUTO 

#============================================================================ 
# Configure ThreadPool 
#============================================================================ 

org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool 
org.quartz.threadPool.threadCount = 25 
org.quartz.threadPool.threadPriority = 5 

#============================================================================ 
# Configure JobStore 
#============================================================================ 

org.quartz.jobStore.misfireThreshold = 60000 

org.quartz.jobStore.class = org.quartz.impl.jdbcjobstore.JobStoreTX 
org.quartz.jobStore.driverDelegateClass = org.quartz.impl.jdbcjobstore.StdJDBCDelegate 
org.quartz.jobStore.useProperties = false 
org.quartz.jobStore.dataSource = development 
org.quartz.jobStore.tablePrefix = Z_STAFF_SCHEDULER_ 

org.quartz.jobStore.isClustered = true 
org.quartz.jobStore.clusterCheckinInterval = 20000 

#============================================================================ 
# Configure Datasources 
#============================================================================ 


org.quartz.dataSource.development.driver = com.mysql.jdbc.Driver 
org.quartz.dataSource.development.URL = jdbc:mysql://localhost:3306/testing?useSSL=false 
org.quartz.dataSource.development.user = testing 
org.quartz.dataSource.development.password = nopass 
org.quartz.dataSource.development.maxConnections = 10 
org.quartz.dataSource.development.validationQuery = select 1 

任何人谁可以帮助我吗?

我使用grails 3.2.3和quartz插件2.0.9

回答

1

我终于找到了解决方案。石英插件的每个选项都可以在application.yml中进行配置。请参阅http://www.quartz-scheduler.org/documentation/quartz-2.2.x/configuration/以获取支持的参数列表。

你不需要任何进一步的文件。下面是从我application.yml提取物作为例子:

quartz: 
    autoStartup: true 
    jdbcStore: true 
    scheduler: 
    instanceName: 'staff_scheduler' 
    instanceId: 'AUTO' 
    threadPool: 
    class: 'org.quartz.simpl.SimpleThreadPool' 
    threadCount: 25 
    threadPriority: 5 
    jobStore: 
    misfireThreshold: 60000 
    class: 'org.quartz.impl.jdbcjobstore.JobStoreTX' 
    driverDelegateClass: 'org.quartz.impl.jdbcjobstore.StdJDBCDelegate' 
    useProperties: false 
    dataSource: 'development' 
    tablePrefix: 'Z_STAFF_SCHEDULER_' 
    isClustered: true 
    clusterCheckinInterval: 20000 
    dataSource: 
    development: 
     driver: 'com.mysql.jdbc.Driver' 
     URL: 'jdbc:mysql://localhost:3306/testing?useSSL=false' 
     user: 'testing' 
     password: 'nopass' 
     maxConnections: 28 
     validationQuery: 'select 1' 
+0

我用你的配置,但是,2017年7月7日16:39:18.602错误org.springframework.boot.SpringApplication.reportFailure - 应用程序启动失败 org.quartz .JobPersistenceException:无法获取作业名称:表'dev_erp2_db.z_staff_scheduler_job_details'不存在 – Denny

+0

@denny您需要先为石英创建数据库模式。不幸的是,插件不会为你自己做。你可以在这里找到一个sql脚本:https://github.com/elventear/quartz-scheduler/blob/master/distribution/src/main/assembly/root/docs/dbTables/tables_mysql.sql – Fmeuer

+0

非常感谢! – Denny