2011-12-06 119 views
2

我在Apache Tomcat上有一個Web應用程序。該Web應用程序使用Quartz Scheduler。我從與-D開關,它包含以下屬性的類路徑加載quartz.properties如何在Tomcat中使用Spring風格的屬性文件配置quartz scheduler?

quartz.jndi=java:comp/env/something 
org.quartz.dataSource.myJndiName.jndiURL=${quartz.jndi} 

但它無法正常工作。也許,${quartz.jndi}只適用於Spring Context和PropertyPlaceholderConfigurer bean?是否有可能在Quartz Scheduler中爲Spring加載這個屬性文件?

回答

0

這取決於你想要什麼類型的Quartz屬性,可能已經有一種通過它的Spring方法。通常用於引用Spring 3之前和之後的屬性條目(非Quartz特有的)look at this question。對於Quartz專用的Spring安裝和配置,請看Spring scheduling documentation的第一部分。

7

過了一年之後,我知道,但希望對大家有用某人:

<bean name="schedulerFactory" depends-on="flyway" class="org.springframework.scheduling.quartz.SchedulerFactoryBean"> 
    <property name="quartzProperties"> 
     <map> 
      <entry key="org.quartz.threadPool.class" value="org.quartz.simpl.SimpleThreadPool" /> 
      <entry key="org.quartz.jobStore.useProperties" value="true" /> 
      <entry key="org.quartz.jobStore.class" value="org.quartz.impl.jdbcjobstore.JobStoreTX" /> 
      <entry key="org.quartz.jobStore.driverDelegateClass" value="org.quartz.impl.jdbcjobstore.StdJDBCDelegate" /> 
      <entry key="org.quartz.jobStore.tablePrefix" value="QRTZ_" /> 
      <entry key="org.quartz.jobStore.dataSource" value="qzDS" /> 
      <entry key="org.quartz.dataSource.qzDS.jndiURL" value="java:comp/env/jdbc/${jndi.dataSource}"/> 
     </map> 
    </property> 
    <property name="applicationContextSchedulerContextKey"> 
     <value>applicationContext</value> 
    </property> 
</bean> 

通知我已經把大部分的作業存儲相關的屬性:你可以通過設置你的Spring上下文XML中的屬性做到這一點在這裏,因爲他們似乎需要在同一個地方。在通常的quartz.properties文件中還有一些其他配置。

+0

是什麼遷徙路線? – huahsin68

+0

flyway是一個數據庫遷移框架。 – TomL

1

您可以在SchedulerFactoryBean來設置configLocation

<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean"> 
    <property name="configLocation" value="classpath:quartz.properties" /> 
    [...] 
</bean> 
相關問題