Quartz在Spring中的运用
Quartz在Spring中的使用
value是corn表达式
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>
1 楼
lihua2008love
2011-09-30
请问,执行的时间间隔在那里定义?
value中是什么?乱码么?
<property name="cronExpression"> 42. <value>0 0 1 ? * *</value> 43. </property>
value中是什么?乱码么?
2 楼
gary0416
2011-10-09
lihua2008love 写道
请问,执行的时间间隔在那里定义?
value中是什么?乱码么?
<property name="cronExpression"> 42. <value>0 0 1 ? * *</value> 43. </property>
value中是什么?乱码么?
value是corn表达式