gpt4 book ai didi

java - Spring 3 + Quartz 2 错误

转载 作者:IT老高 更新时间:2023-10-28 13:48:20 26 4
gpt4 key购买 nike

我在使用 Spring 3 和 Quartz 2 时收到以下错误。有人知道原因吗?

错误:

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)

Spring 配置文件:

<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 {
*****
}

}

最佳答案

如果你使用 Spring 3.1,

将 SimpleTriggerBean 替换为 SimpleTriggerFactoryBean

在 3.1 版本中,Spring 为 crontrigger 和 simpletrigger 创建了 Factory 类

更新:

Using Spring 3.2.2, must be useful to change also JobDetailBean => JobDetailFactoryBean and CronTriggerBean => CronTriggerFactoryBean.

感谢 Osy(对下面的评论投票)

关于java - Spring 3 + Quartz 2 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8245218/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com