Web applications Quartz配置文件(Quartz.properties)如何根据数据库类型动态拾取jobstore驱动程序类

Web applications Quartz配置文件(Quartz.properties)如何根据数据库类型动态拾取jobstore驱动程序类,web-applications,quartz-scheduler,Web Applications,Quartz Scheduler,我在web应用程序中使用Quartz,Jobstore作为JDBC JobStoreCMT,而不是默认的RAMJobStore。我的应用程序将使用Mssql或Oracle数据库,具体取决于客户。 每次我将数据库从Oracle更改为Mssql或其他类型时,都必须更改quartz.properties文件中的driverDelegateClass属性值。我的quartz.properties文件如下 MSSQL- # Default Properties file for use by StdSch

我在web应用程序中使用Quartz,Jobstore作为JDBC JobStoreCMT,而不是默认的RAMJobStore。我的应用程序将使用Mssql或Oracle数据库,具体取决于客户。 每次我将数据库从Oracle更改为Mssql或其他类型时,都必须更改quartz.properties文件中的driverDelegateClass属性值。我的quartz.properties文件如下

MSSQL-

# Default Properties file for use by StdSchedulerFactory
# to create a Quartz Scheduler Instance, if a different
# properties file is not explicitly specified.
#

org.quartz.scheduler.instanceName: DatabaseScheduler
org.quartz.scheduler.rmi.export: false
org.quartz.scheduler.rmi.proxy: false
org.quartz.scheduler.wrapJobExecutionInUserTransaction: false

org.quartz.threadPool.class: org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount: 5
org.quartz.threadPool.threadPriority: 5
org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread: true

org.quartz.jobStore.misfireThreshold: 60000


# Changes for JDBCJobStoreTX

org.quartz.jobStore.class = org.quartz.impl.jdbcjobstore.JobStoreCMT
org.quartz.jobStore.driverDelegateClass = org.quartz.impl.jdbcjobstore.MSSQLDelegate
org.quartz.jobStore.dataSource = quartzDataSource
org.quartz.jobStore.tablePrefix = QRTZ_
org.quartz.scheduler.skipUpdateCheck = true
org.quartz.scheduler.jobFactory.class = org.quartz.simpl.SimpleJobFactory
神谕-

org.quartz.scheduler.instanceName: NDFSScheduler
org.quartz.scheduler.rmi.export: false
org.quartz.scheduler.rmi.proxy: false
org.quartz.scheduler.wrapJobExecutionInUserTransaction: false

org.quartz.threadPool.class: org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount: 25
org.quartz.threadPool.threadPriority: 5
org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread: true

org.quartz.jobStore.misfireThreshold: 60000


# Changes for JDBCJobStoreTX

org.quartz.jobStore.class = org.quartz.impl.jdbcjobstore.JobStoreCMT
org.quartz.jobStore.driverDelegateClass = org.quartz.impl.jdbcjobstore.oracle.OracleDelegate
org.quartz.jobStore.dataSource = quartzDataSource
org.quartz.jobStore.tablePrefix = QRTZ_
org.quartz.scheduler.skipUpdateCheck = true
org.quartz.scheduler.jobFactory.class = org.quartz.simpl.SimpleJobFactory

是否有任何方法,我不需要进行此设置,quartz将根据数据库自动拾取正确的driverDelegateClass。或者该属性(driverDelegateClass)从不同的文件中获取的任何方式?

假设您使用StdSchedulerFactory#getScheduler方法在代码中以编程方式实例化Quartz调度程序实例,然后,您可以使用以下两个StdSchedulerFactory构造函数之一,它们允许您传递一组不同的属性(想想quartz.properties)

注意:文件名可以是位于应用程序类路径上的资源,也可以是位于应用程序外部的文件

在代码中,您可以根据应用程序的配置选择不同的quartz.properties文件(例如quartz-mssql.properties、qqrtz-oracle.properties),轻松地在各种数据库配置文件之间切换

如果您使用Spring(即SchedulerFactoryBean类)来构造Quartz调度器实例,那么您可以使用PropertyPlaceHolderConfigure来实现相同的功能

StdSchedulerFactory(Properties props) 
StdSchedulerFactory(String fileName)