spring quarz 整合

需要包: spring.jar(我使用的是2.5.2) quartz-all-1.6.0.jar log4j-1.2.14.jar jta.jar commons-logging.jar commons-collections.jar

配置文件:

<?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"
       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">
       
       <bean id="testScheduler" class="com.zhengmenbb.TestScheduler"></bean>
       
       <bean id="jobtask"  
        class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
        <property name="targetObject">
            <ref bean="testScheduler" />
        </property>  
        <property name="targetMethod">
            <value>testJob</value>
        </property>  
    </bean>  
       
    <bean id="doTime" class="org.springframework.scheduling.quartz.CronTriggerBean">
        <property name="jobDetail">
            <ref bean="jobtask" />
        </property>  
           
        <property name="cronExpression">
            <value>0 0/1 * * * ?</value>
        </property>
    </bean>
       
    <bean id="startQuertz" lazy-init="false"   class="org.springframework.scheduling.quartz.SchedulerFactoryBean" >
        <property name="triggers">
            <list>  
                <ref bean="doTime" />
            </list>  
        </property>  
    </bean>  
    
       </beans>

java code :

package com.zhengmenbb;

public class TestScheduler {
    public void testJob() {
        System.out.println("hello spring + quarz");
    }
}

我使用的是每分run一次。

附:cronExpression表达式解释:
0 0 12 * * ?—————在每天中午12:00触发
0 15 10 ? * *—————每天上午10:15 触发
0 15 10 * * ?—————每天上午10:15 触发
0 15 10 * * ? *—————每天上午10:15 触发
0 15 10 * * ? 2005—————在2005年中的每天上午10:15 触发
0 * 14 * * ?—————每天在下午2:00至2:59之间每分钟触发一次
0 0/5 14 * * ?—————每天在下午2:00至2:59之间每5分钟触发一次
0 0/5 14,18 * * ?—————每天在下午2:00至2:59和6:00至6:59之间的每5分钟触发一次
0 0-5 14 * * ?—————每天在下午2:00至2:05之间每分钟触发一次
0 10,44 14 ? 3 WED—————每三月份的星期三在下午2:00和2:44时触发
0 15 10 ? * MON-FRI—————从星期一至星期五的每天上午10:15触发
0 15 10 15 * ?—————在每个月的每15天的上午10:15触发
0 15 10 L * ?—————在每个月的最后一天的上午10:15触发
0 15 10 ? * 6L—————在每个月的最后一个星期五的上午10:15触发
0 15 10 ? * 6L 2002-2005—————在2002, 2003, 2004 and 2005年的每个月的最后一个星期五的上午10:15触发
0 15 10 ? * 6#3—————在每个月的第三个星期五的上午10:15触发
0 0 12 1/5 * ?—————从每月的第一天起每过5天的中午12:00时触发
0 11 11 11 11 ?—————在每个11月11日的上午11:11时触发.-

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值