scheduling.quartz.CronTriggerBean has interface org.quartz.CronTrigger as super class

转自:https://blog.csdn.net/lzj0470/article/details/17786587

quartz版本号:2.1.7

错误:

 Caused by: <a href="http://lib.csdn.net/base/17" class="replace_word" title="Java EE知识库" target="_blank" style="color:#df3434; font-weight:bold;">java</a>.lang.IncompatibleClassChangeError: class org.springframework.scheduling.quartz.CronTriggerBean has interface org.quartz.CronTrigger as super class
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2854)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1159)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1647)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
at org.springframework.util.ClassUtils.forName(ClassUtils.java:260)
at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:416)
at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1290)
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1261)

解决:

将CronTriggerBean修改为CronTriggerFactoryBean。如:

 <bean id="CronTriggerBean" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
<property name="jobDetail" ref="myjob"/>
<property name="cronExpression" value="0/2 * * * * ?"/>
</bean>

注意:

由于Quartz 2.x修改了部分API,所以需要修改一下Quartz的配置。大体来说很简单,如下:

1)升级Spring的jar包

2)升级Quartz的jar包

3)修改配置

  • 将CronTriggerBean修改为CronTriggerFactoryBean
  • 将JobDetailBean修改为JobDetailFactoryBean
上一篇:quartz详解2:quartz由浅入深


下一篇:企业级任务调度框架Quartz(3) 一个简单的Quartz 例子