Spring整合Quartz2.x,需要使用Spring3.1以上的版本。由于Quartz 2.x修改了部分API,所以需要修改一下Quartz的配置。跟老版本需要做如下修改:
将CronTriggerBean修改为CronTriggerFactoryBean
将JobDetailBean修改为JobDetailFactoryBean
quartz需要使用到的包为:quartz-2.2.0.jar,包括log4j依赖包
spring的参考网址为:http://static.springsource.org/spring/docs/3.1.x/spring-framework-reference/html/scheduling.html
具体的配置如下:
<!-- spring定时调度 -->
<bean id="activateCardJobDetail"
class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject"> <!-- targetObject是Spring定时器的特殊属性 -->
<ref bean="dispatchService" />
</property>
<property name="targetMethod"> <!-- targetMethod是Spring定时器的特殊属性 -->
<value>test</value><!-- 这里的doAuth 就是java类中的任务方法 -->
</property>
</bean>
<bean id="activateCardTaskTriggerBean" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
<property name="jobDetail"><!-- jobDetail是Spring定时器的特殊属性 -->
<ref bean="activateCardJobDetail" />
</property>
<property name="cronExpression">
<value>*/10 * * ? * *</value><!-- cronExpression是Spring定时器的特殊属性 -->
</property>
</bean>
<bean autowire="no"
class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers"> <!-- triggers是Spring定时器的特殊属性 -->
<list>
<ref local="activateCardTaskTriggerBean" />
</list>
</property>
</bean>
分享到:
相关推荐
16.7.2 使用Spring Servlet API模拟对象 16.7.3 使用Spring RestTemplate测试 16.7.4 使用Selenium测试 16.8 小结 第17章 实战案例开发 17.1 论坛案例概述 17.1.1 论坛整体功能结构 17.1.2 论坛用例描述 17.1.3 主要...
13.9.2. form标签 13.9.3. input标签 13.9.4. checkbox标签 13.9.5. radiobutton标签 13.9.6. password标签 13.9.7. select标签 13.9.8. option标签 13.9.9. options标签 13.9.10. textarea标签 13.9.11. hidden标签...
13.9.2. form标签 13.9.3. input标签 13.9.4. checkbox标签 13.9.5. checkboxes标签 13.9.6. radiobutton标签 13.9.7. radiobuttons标签 13.9.8. password标签 13.9.9. select标签 13.9.10. option标签 ...
13.11.2. 对模型的支持:ModelMap (ModelAndView) 13.11.3. 对视图的支持: RequestToViewNameTranslator 13.12. 其它资源 14. 集成视图技术 14.1. 简介 14.2. JSP和JSTL 14.2.1. 视图解析器 14.2.2. 'Plain-...
11.7.2. 处理BLOB 和 CLOB对象 11.7.3. 在IN语句中传入一组参数值 11.7.4. 处理复杂类型的存储过程调用 12. 使用ORM工具进行数据访问 12.1. 简介 12.2. Hibernate 12.2.1. 资源管理 12.2.2. 在Spring容器中...
16.7.2 使用Spring Servlet API模拟对象 16.7.3 使用Spring RestTemplate测试 16.7.4 使用Selenium测试 16.8 小结 第17章 实战案例开发 17.1 论坛案例概述 17.1.1 论坛整体功能结构 17.1.2 论坛用例描述 17.1.3 主要...
13.9.2. form标签 13.9.3. input标签 13.9.4. checkbox标签 13.9.5. radiobutton标签 13.9.6. password标签 13.9.7. select标签 13.9.8. option标签 13.9.9. options标签 13.9.10. textarea标签 13.9.11. ...
6.3 将Spring与Struts 1.x集成 220 6.3.1 问题 220 6.3.2 解决方案 220 6.3.3 工作原理 220 6.4 将Spring与JSF集成 226 6.4.1 问题 226 6.4.2 解决方案 226 6.4.3 工作原理 227 6.5 将Spring与DWR...
6.3 将Spring与Struts 1.x集成 220 6.3.1 问题 220 6.3.2 解决方案 220 6.3.3 工作原理 220 6.4 将Spring与JSF集成 226 6.4.1 问题 226 6.4.2 解决方案 226 6.4.3 工作原理 227 6.5 将Spring与DWR...
1.1修改tomcat8.x/conf/context.xml的配置如下: <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this ...
4.4 用Spring整合Hibernate 4.4.1 Hibernate概览 4.4.2 管理Hibernate资源 4.4.3 用HibernateTemplate访问Hibernate 4.4.4 HibernateDaoSupport的子类 4.5 Spring和JDO 4.5.1 配置JDO ...
- 定时任务:整合Quartz做定时任务,加入任务日志,任务运行情况一目了然 - 代码生成:高灵活度生成前后端代码,减少大量重复的工作任务(逆向有很多方案,这种基于template的有一定的灵活性) - 邮件工具:配合富...
1.4、SpringBoot和SpringCloud区别 2 1.5常见错误 2 二、快速入门 2 2.1、创建一个Maven工程 2 2.2、pom文件引入依赖 3 2.3、编写HelloWorld服务 3 2.4、@RestController 4 2.5、@EnableAutoConfiguration 4 ...