복붙노트

[SPRING] 봄 3 + 석영 2 오류

SPRING

봄 3 + 석영 2 오류

내가 석영 2와 스프링 3 사용할 때 아래 오류가 나타났습니다. 이유를 아는 사람이 있습니까?

오류:

Exception in thread "main" org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [org.springframework.scheduling.quartz.JobDetailBean] for bean with name 'job' defined in class path resource [beans.xml]: problem with class file or dependent class; nested exception is java.lang.IncompatibleClassChangeError: class org.springframework.scheduling.quartz.JobDetailBean has interface org.quartz.JobDetail as super class
    at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1253)

봄 설정 파일 :

<bean name="job" class="org.springframework.scheduling.quartz.JobDetailBean">
  <property name="jobClass" value="Example.ExampleJob"/>
  <property name="jobDataAsMap">
    <map>
      <entry key="timeout" value="5"/>
    </map>
  </property>
</bean>

<bean id="simpleTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerBean">
  <property name="jobDetail" ref="job"/>
  <property name="startDelay" value="1000"/>
  <property name="repeatInterval" value="5000"/>
</bean>

public class ExampleJob extends QuartzJobBean {

      private int timeout;

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

    @Override
    protected void executeInternal(JobExecutionContext ctx)
            throws JobExecutionException {
        *****
    }

}

해결법

  1. ==============================

    1.마지막으로 확인한 바, Spring은 Quartz 2를 지원하지 않습니다. 가장 최근의 Spring 빌드가 지원을 추가했는지 확인하거나 Quartz 1.8.x로 다운 그레이드 해보십시오.

    마지막으로 확인한 바, Spring은 Quartz 2를 지원하지 않습니다. 가장 최근의 Spring 빌드가 지원을 추가했는지 확인하거나 Quartz 1.8.x로 다운 그레이드 해보십시오.

  2. ==============================

    2.Spring 3.1을 사용한다면,

    Spring 3.1을 사용한다면,

    SimpleTriggerBean을 SimpleTriggerFactoryBean으로 대체하십시오.

    3.1 릴리스에서 Spring은 crontrigger 및 simpletrigger에 대한 Factory 클래스를 작성했습니다.

    최신 정보:

    지불 신용 (아래 의견에 투표)

  3. ==============================

    3.3.1.0.RC1 변경 로그에 따르면, Spring 3.1은 Quartz 2.x를 지원한다.

    3.1.0.RC1 변경 로그에 따르면, Spring 3.1은 Quartz 2.x를 지원한다.

    모든 {Type} TriggerBean에는 트리거를 설정하는 데 사용할 수있는 {Type} TriggerBeanFactory가 있습니다. 귀하의 경우에는 SimpleTriggerFactoryBean이됩니다.

    발췌

    또한 사용중인 트리거 유형에 따라 org.springframework.transaction 종속성을 추가해야 할 수도 있습니다.

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-tx</artifactId>
        <version>3.1.2.RELEASE</version>
    </dependency>
    

    CronTriggerFactoryBean 트리거를 사용하는 구성에서 Quartz 2 로의 마이그레이션이 필요했습니다.

  4. ==============================

    4.Spring 3.x 및 Quartz 2.1.x를 사용하는 경우 ...

    Spring 3.x 및 Quartz 2.1.x를 사용하는 경우 ...

    그런 다음 구성 파일에서 두 가지 변경 만 수행하십시오. 1 단계 : 단순 트리거 용

    대신에 class = "org.springframework.scheduling.quartz.SimpleTriggerFactoryBean">을 사용하십시오. class = "org.springframework.scheduling.quartz.SimpleTriggerBean">

    2 단계 : Cron 트리거 대신 class = "org.springframework.scheduling.quartz.CronTriggerFactoryBean"을 사용하십시오. class = "org.springframework.scheduling.quartz.CronTriggerBean"

  5. from https://stackoverflow.com/questions/8245218/spring-3-quartz-2-error by cc-by-sa and MIT license