2011-05-19 55 views
1

我使用的是Spring-Version:2.0.7,我需要下載石英庫和它們的依賴來使用它嗎?因爲起初我雖然需要它,但它給了我一個java.lang.IncompatibleClassChangeError。Spring-Version:2.0.7集成石英?

所以我想,也許它被集成在spring.jar中,因爲根據2.5 spring會在spring庫中調用應用程序上下文。

如何當我刪除quarta.jar,我無法訪問JobExecutionContext類。這裏是我的bean聲明:

<bean name="exampleJob" class="org.springframework.scheduling.quartz.JobDetailBean"> 
     <property name="jobClass" value="com.bamboo.common.util.CheckAndProcessFilesJob" /> 
    <property name="jobDataAsMap"> 
    <map> 
     <entry key="timeout" value="5" /> 
    </map> 
    </property> 
</bean> 

Java代碼

package com.bamboo.common.util; 

import org.springframework.scheduling.quartz.QuartzJobBean; 


    /** 
    * Created by IntelliJ IDEA. 
    * User: ernestobuttolazio 
    * Date: 19-may-2011 
    * Time: 16:44:54 
    * To change this template use File | Settings | File Templates. 
    */ 
    public class CheckAndProcessFilesJob extends QuartzJobBean { 
     private int timeout; 

     private int contador; 
     /** 
     * Setter called after the ExampleJob is instantiated 
     * with the value from the JobDetailBean (5) 
     */ 
     public void setTimeout(int timeout) { 
     this.timeout = timeout; 
     } 

    protected void executeInternal(JobExecutionContext ctx) throws JobExecutionException { 
      // do the actual work 
     contador += timeout; 
     } 

    } 
+0

您嘗試使用哪個版本的Quartz? – 2011-05-19 21:29:35

回答

2

你需要使用Quartz 1.8.x的或更早的使用Spring的當前包裝。 Quartz 2.0不適用於他們。

你可以沿着Spring使用Quartz 2.0沒有問題 - 只是沒有Spring的包裝。

+0

謝謝jhouse – Ernest 2011-05-19 23:14:17

+0

這是相關的bug:https://jira.springsource.org/browse/SPR-8275 – depsypher 2011-06-24 18:36:23

3

您需要使用石英2.1.6。 JobDetailFactoryBean應該到位JobDetailBean.The配置看起來像如果使用的是帶有集羣石英使用,

<bean name="sampleJobDetail" 
      class="org.springframework.scheduling.quartz.JobDetailFactoryBean"> 
      <property name="jobClass" 
       value="com.altisource.scheduler.jobs.SampleJob" /> 
      <property name="jobDataAsMap"> 
       <map> 
       </map> 
      </property> 

     </bean> 

     <bean id="sampleTrigger" 
      class="org.springframework.scheduling.quartz.SimpleTriggerFactoryBean"> 
      <property name="jobDetail" ref="sampleJobDetail" /> 
      <property name="startDelay" value="30000" /> 
      <property name="repeatInterval" value="30000" /> 
      <property name="group" value="YOURCHOICE" /> 
     </bean> 

,調度工廠org.springframework.scheduling.quartz.SchedulerFactoryBean將只需要財產triggers和限制提供jobDetails。確保配置調度器工廠org.springframework.scheduling.quartz.SchedulerFactoryBean只有triggers