Quartz项目主页http://www.quartz-scheduler.org/
SSHJob.java
package ssh.core;
import org.apache.log4j.Logger;
/**
* SSH系统任务
* @author gary
*
*/
public class SSHJob {
Logger log = Logger.getLogger(this.getClass());
public void work(){
log.debug("SSH System job");
}
}
applicationContext-quartz.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://cxf.apache.org/jaxws
http://cxf.apache.org/schemas/jaxws.xsd"
default-lazy-init="true">
<!-- 调用的类 -->
<bean id="sshJob" class="ssh.core.SSHJob" />
<bean id="sshJobTask" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<!-- 调用的类 -->
<property name="targetObject">
<ref bean="sshJob"/>
</property>
<!-- 调用类中的方法 -->
<property name="targetMethod">
<value>work</value>
</property>
</bean>
<bean id="sshJobDoTime" class="org.springframework.scheduling.quartz.CronTriggerBean">
<!-- 要触发的任务 -->
<property name="jobDetail">
<ref bean="sshJobTask"/>
</property>
<!-- cron表达式,详见 http://www.quartz-scheduler.org/docs/tutorials/crontrigger.html -->
<property name="cronExpression">
<value>0 0 1 ? * *</value>
</property>
</bean>
<!-- lazy-init="false"则容器启动就会执行调度程序 -->
<bean id="startQuartz" lazy-init="true" autowire="no"
class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="sshJobDoTime"/>
</list>
</property>
</bean>
</beans>
分享到:
相关推荐
quartz 在spring中使用服务定时执行的例子,及全部的jar包
quartz在spring中的配置,特别是ssh中的配置应用
Quartz在Spring中动态设置cronExpression
Quartz 是一个强大的企业级 Schedule 工具,也是目前最好的开源 Schedule 工具。实例中quartz在spring中的应用及quartz详细时间配置。
Quartz + spring的开发步骤Quartz + spring的开发步骤
Quartz在Spring中动态设置cronExpression.docx 相当不错的资料 小而全面
关于spring中quartz的配置
Spring Quartz如何动态配置时间
本人花费多日时间,亲测有效。所需文件代码完整,只需导入常用开发IDE和mysql数据库即可正常使用。
spring的quartz使用实例,spring的quartz使用实例
quartz2.2.1 spring3.1.1,quartz含源码(src文件夹,通过eclipse导入源码时,选择导入文件夹即可)
quartz与spring集群, quartz与spring,quartz与spring
Quartz定时器。Spring中Quartz的配置
spring2.0 使用 Quartz 必备包 里面有: quartz-all-1.5.2.jar spring-support.jar 适合:SSH框架 spring2.0 strut2.0 hibernate3.2等
Spring中Quartz调度器的使用 示例代码
各种企业应用几乎都会碰到任务调度的需求...对于一个典型的MIS系统来说,在每月1号凌晨统计上个月各部门的业务数据生成月报表,每半个小时查询用户是否已经有快到期的待处理业 务……,这样的例子俯拾皆是,不胜枚举。
好像很多人整合出现了问题,所以抽个demo出来 是一个demo包含源码和lib 在tomcat下可以执行
Quartz与Spring整合练习源代码,本文博客地址http://blog.csdn.net/Earl_yuan/article/details/50668864