请教,spring3.2+quartz2.1.6报如下错误如何解决?
class org.springframework.scheduling.quartz.JobDetailBean has interface org.quartz.JobDetail as super class
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd"> <beans> <bean name="quartzScheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean"> <property name="dataSource"> <ref bean="dataSource" /> </property> <property name="applicationContextSchedulerContextKey" value="applicationContextKey" /> <property name="configLocation" value="classpath:quartz.properties" /> </bean> <bean id="jobDetail" class="org.springframework.scheduling.quartz.JobDetailBean"> <property name="jobClass" value="com.example.service.MyQuartzJobBean" /> <property name="jobDataAsMap"> <map> <entry key="simpleService"> <ref bean="simpleService" /> </entry> </map> </property> </bean> </beans>
public class MyQuartzJobBean extends QuartzJobBean { private SimpleService simpleService; @Autowired public void setSimpleService(SimpleService simpleService) { this.simpleService = simpleService; } @Override protected void executeInternal(JobExecutionContext jobexecutioncontext) throws JobExecutionException { Trigger trigger = jobexecutioncontext.getTrigger(); String triggerName = trigger.getKey().getName(); simpleService.testMethod(triggerName); } }
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(10)
Spring官网有说明其已支持Quartz 2.x,但是需要将Spring升级到3.1以上。由于Quartz 2.x修改了部分API,所以需要修改一下Quartz的配置。大体来说很简单,如下:
1)升级Spring的jar包
2)升级Quartz的jar包
3)修改配置
引用来自“零度C”的评论
Spring官网有说明其已支持Quartz 2.x,但是需要将Spring升级到3.1以上。由于Quartz 2.x修改了部分API,所以需要修改一下Quartz的配置。大体来说很简单,如下:
1)升级Spring的jar包
2)升级Quartz的jar包
3)修改配置
兄弟,你点进去这个类org.springframework.scheduling.quartz.JobDetailBean看看他的提示啊!!
NOTE: This convenience subclass does not work against Quartz 2.0.</b>
Use Quartz 2.0's native <code>JobDetailImpl</code> class or the new Quartz 2.0 builder API instead. Alternatively, switch to Spring's
{@link JobDetailFactoryBean}
which largely is a drop-in replacement for this class and its properties and
consistently works against Quartz 1.x as well as Quartz 2.0/2.1.
Quartz 2.0/2.1使用的是org.springframework.scheduling.quartz.JobDetailFactoryBean
spring早已经支持quartz2.x,请看这里
http://shellblog.sinaapp.com/?p=395
介个我刚刚踩过这个坑。。。
直接用Spring 的 Task就行,不用加任何Jar包,支持注解
可以参考:http://static.springsource.org/spring/docs/3.1.x/spring-framework-reference/html/scheduling.html
或者直接搜索
已经支持
木有吧
与Spring整合必须请使用Quartz1.8.x及以下版本
与Spring整合必须请使用Quartz1.8.x及以下版本
Spring3.1.0 能匹配quartz2.2.1吗