先看一个例子

一.demo1(MethodInvokingJobDetailFactoryBean

1.要执行业务类

public class BusinessReport {
public void perform(){
System.out.println("sdfdsafasdfadsfaf");
}
}

2.applicationContext2.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"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd"> <bean id="businessReport" class="BusinessReport">
</bean> <!-- 在Spring配置文件中配置代理类MethodInvokingJobDetailFactoryBean,定义任务的详细信息。 -->
<bean id="reportTask" class= "org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject" ref="businessReport" />
<property name="targetMethod" value="perform" />
<property name="concurrent" value="false " />
</bean>
<!-- 配置一个触发器。在Spring配置文件中配置触发器类CronTriggerBean -->
<bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail" ref="reportTask" />
<property name="cronExpression" value="0/5 * * * * ?" />
</bean>
<!-- 配置一个调度器。在Spring配置文件中配置调度器类SchedulerFactoryBean -->
<bean class= "org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="cronTrigger" />
</list>
</property>
</bean>
</beans>

3.测试

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
* Hello world!
*
*/
public class App
{
public static void main( String[] args )
{
ApplicationContext appContext = new ClassPathXmlApplicationContext("applicationContext2.xml"); }
}

4.结果,每个5秒打印一个

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAASQAAABWCAIAAADpBnzFAAAFtElEQVR4nO2b3ZmsIAyGqcuCqIcStgqaoYnpIOfCUQGD4l/Ozs77Pnux40AMwkeAMe71ev38/Lxer9frJfApRC/OLx+9k5AO1S+q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RzztaBJ/MHWKLvjl8Tottw2Y//X72VFfpt3lLi+CTuUFsW2PyrNjOR8S2lcM2Oyr027ynRfDJNFNspiVPNh1nF53zsbowXVRLtmxGX5dr2VyXvO7nrs0N5/ttNp8SfBm62KJfj4jo52GyEzH0kprNjFPR8pqfqs1jzvdHdSIb6GJ7T8b54Mi3HNvDqFFSsSllINgemlrJS36qNg853+2nXhK+jM092zhu5hn/mtgUm3nR/Wiplzzvp2rzgPPH/ERssHdAMo+RFIZit9IeRu2SbZvjMO6xWZe8w8/MZr/zB/1EbKCKTT0iWK76WGxh1sNIK6nbnNdcQwjbNrWSV/1U797vfL9NtSR8G7xBAmAEYgMwArEBGIHYAIxAbABGIDYAI0ix6a9+0U9SbL4dUmy6q6uQYgPdkGJzyQlSbKAfUmy2bJJiAzdCik31HSk28BSk2JQ2SbGBxyDFpvyOFBt4DFJsSpuk2MBjkGJT350UG3gI3iABMAKxARiB2ACMQGwARiA2ACMQG4ARpNj0V7/oJyk23w4pNt3VVUixgW5IsbnkBCk20A8pNls2SbGBGyHFpvqOFBt4ClJsSpuk2MBjkGJTfkeKDTwGKTalTVJs4DFIsanvTooNPARvkAAYgdgAjEBsAEYgNgAjEBuAEYgNwAjEBmAEYgMwArEBGIHYAIxAbABGIDYAIxAbgBGIDcAIxAZgBGIDMAKxARiB2ACMQGwARiA2ACMQG4ARiA3ACMQGYARiAzACsQEYgdgAjPgH8hmfO6MbdOcAAAAASUVORK5CYII=" alt="" />

5所需包,spring包最好3.2以上,不然可能报缺少包

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAYoAAAFnCAIAAAA3xpkbAAAgAElEQVR4nO2dT2wcx53vefGdBwObo9d/BAMGNkIQGMG8wx5lI+cHyLq83X0wkQUekre5WAEcvNFbxxAUBR57rYwWMrzSwQQdgBv9Wc1SthRLjBhrba9M2fEsIz5LskSHCmdIkSI1nJGl9DvMn64/v6qu6ek/VdXfLxoCp7u6uro59VFVz/SHY0FCmZycbDQaR44cWV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Ak/N4StQ17k1UvvN4HvSIvaAbTynAk/N4CpJ0jXsUle88ngddtRd042kGePIBTwjiZTzuBZ7gCQsWLHl3x+QDPGHB4smSd3dMPsATFiyeLHl3x+TjNp4QBPE4wBOCIJYGeEIQxNIATwiCWBr38PTbnz87WHJpAIIg2cQKPM3NzW1tbZmUnP5fT2peIgjiU6zA0+Tk5NTUVLPZ1Bf77c+ebd8+3L59eH2hcnt+/43zexeO/+/f/uxZdkmqSQiC5B5b8LSysnLkyBG9tunsz77TXr+kWc7+7Dua3RV6RlZuLTvFEQTJLbbgKQiCZrOpl16e/T/fad8+rlne/h+PKY9B2DwEubX5o/kIgmQRi/AUBEGkMnzlP/7lq3f++8p//EsQBNM//rZmkXaVzdw8seJZjRAESS2j4On/A9kQx6aqrQFlAAAAAElFTkSuQmCC" alt="" />


二.demo2(JobDetailBean

1.要执行业务类

import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
public class BusinessReport implements Job{
public void perform(){
System.out.println("JobJobJobJob");
}
public void execute(JobExecutionContext arg0) throws JobExecutionException {
// TODO Auto-generated method stub
perform();
}
}

2.applicationContext.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"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd"> <bean id="businessReport" class="BusinessReport">
</bean> <!-- 我们的任务 -->
<bean name="reportTask" class= "org.springframework.scheduling.quartz.JobDetailBean">
<property name="jobClass" value="BusinessReport" />
</bean>
<!-- 配置一个触发器。在Spring配置文件中配置触发器类CronTriggerBean -->
<bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail" ref="reportTask" />
<property name="cronExpression" value="0/5 * * * * ?" />
</bean>
<!-- 配置一个调度器。在Spring配置文件中配置调度器类SchedulerFactoryBean -->
<bean class= "org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="cronTrigger" />
</list>
</property>
</bean>
</beans>

3.测试类

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
* Hello world!
*
*/
public class App
{
public static void main( String[] args )
{
ApplicationContext appContext = new ClassPathXmlApplicationContext("applicationContext.xml"); }
}

4.结果,5秒一次

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAS4AAABYCAIAAADELo18AAAFE0lEQVR4nO3bS5akIBCFYdbFgmI9THsffdhHj1lM9EAFFHxkaqZh1f+dGnRli+WDK2ga7s/ff3/+/lM8WhR1kn9R5zS+1r5qbmSTfh1HFH+EpN6pm35CerH5B6J4dpN+HaIImEAUAROIImDCj45iCjwtmLx1N5jCTiuZbgU5yKd9PYpDPIYfyScwqT9zOleaXx7FeuMvW+25fe8fz9Znoqh6+txh1EYxqR+OfnvyksakUcanYfLeqfXaeZb2mSherHoiv7ojbzix8S9sBlG0roliChqjOqdOxs5XTnZS71SiBj8tUImyP1Z0u864tvwzLSCuMwSJ05DHATnUvGxSVCdl+fx4fdjy3cfuwasP5VcZlqy6eN1xT238/GuAjTBsRFEWzaM6KXua97E7ztcfuua6vMxnE8XuOtt971s5R8t1Nn80yuzsPFATRXEa512k7GHSEFdHxSNR1GnNy6O2eWVddPHcVnKTteaLz2OZxZUvoGPpzdunU+YzwOBV4mYfPbnxw2J7g173eEo7WV3b9/pb+OFvLQb/V6PYXefavrd621lfcfK/F5fC8XQ82DyKKaiE+blPGlP598ao+JJlB+p1x9lgVfXm/citfd7tT5+J4gUbrxr80Ynf7HjG3lDZ287Z6DeNyfVBeCOK3XWu7nur94cWMcujRUgaRb0vvz7ZPIoxagya6lHRa6gertSjYjg5H6hfhmq7Y5xfCD8XxXoutzkEvTBBvWLjo7x4mc/H83AUu5eek1Fcu5xdHsXh+ATRGFTi4fXb1UxQhyimWO4P86iYkqagIWmQ8ZYmVif84AQ1W9znyPwmrf5f2R1YmubTWvajmMLRe4z6eWyUajpX3+A1E6o3Nz6+fOdT/ug0eVmssH/JaDZpsZ7lxaX+cGzQuQtod/NMFLsT1BTUi0pQTSqi/qqnaLc5HsWkEjSFMo7FNJtBHYni4gFJ/16/ee4SdgeWtvniyUceLvYesWzPusv2Vye+PGPorfOCjV/vZKvHs17D5rBWzydz+PMexapVZze7B3llnWeiqN0jH8tzneA/8A7tt61EsT7HYYriLCH1xPXJZgUEa6PrrMF1X2MAxY9+2+aIN2p5ynXq8Vdi2PHro0gtD2wgioAJRBEwgSgCJrwdxSjuzItGj24OXG8ZxSgu81vPMPq9+dHNgRutjopRTvXmRzcHvu9YFFPw02gzdeEoTuI0DLX9/tHNge87EMUUfO6u5d9RcteuF/gRzYHv249iCr6ezU1zu3qOt1jk8c2B7yOKRBEmLKKYQpiqgPKd1eocr7rzyrO9BzcH7tRWZvQeZpRvCfLHK18cPLo5cB/etgFMIIqACUQRMIEoAiYQRcAEogiYQJEUYAJFUoAJFEkBJlAkxes2MIEiKYqkYAKVGVRmwASiSBRhAkVSFEnBBIqkuFGECbxtA5hAFAETiCJgAlEETCCKgAlEETCBIinABIqkABMokgJMoEiK121gAkVSFEnBBCozqMyACUSRKMIEiqQokoIJFElxowgTeNsGMIEoAiYQRcAEogiYQBQBE4giYAJFUoAJFEkBJlAkBZhAkRSv28AEiqQokoIJVGZQmQETiCJRhAkUSVEkBRMokuJGESbwtg1gAlEETCCKgAlEceScu3sT8KsRxRFRxL2I4ogo4l4USY2IIu5FkdSIKOJeFEmNiCLuRZHUuCRRxL0okho/JIq4F5UZ4yJEEfciikQRJlAkNS5LFHGv/54bw+OKPvKnAAAAAElFTkSuQmCC" alt="" />



三、Cron表达式的详细用法
字段 允许值 允许的特殊字符
秒 0-59 , - * /
分 0-59 , - * /
小时 0-23 , - * /
日期 1-31 , - * ? / L W C
月份 1-12 或者 JAN-DEC , - * /
星期 1-7 或者 SUN-SAT , - * ? / L C #
年(可选) 留空, 1970-2099 , - * /

例子:
0/5 * * * * ? : 每5秒执行一次

“*”字符被用来指定所有的值。如:"*"在分钟的字段域里表示“每分钟”。
“?”字符只在日期域和星期域中使用。它被用来指定“非明确的值”。当你需要通过在这两个域中的一个来指定一些东西的时候,它是有用的。看下面的例子你就会明白。
月份中的日期和星期中的日期这两个元素时互斥的一起应该通过设置一个问号来表明不想设置那个字段。

“-”字符被用来指定一个范围。如:“10-12”在小时域意味着“10点、11点、12点”。

“,”字符被用来指定另外的值。如:“MON,WED,FRI”在星期域里表示”星期一、星期三、星期五”。

“/”字符用于指定增量。如:“0/15”在秒域意思是每分钟的0,15,30和45秒。“5/15”在分钟域表示每小时的5,20,35和50。
符号“*”在“/”前面(如:*/10)等价于0在“/”前面(如:0/10)。记住一条本质:表达式的每个数值域都是一个有最大值和最小值的集合,如:
秒域和分钟域的集合是0-59,日期域是1-31,月份域是1-12。字符“/”可以帮助你在每个字符域中取相应的数值。如:“7/6”在月份域的时候只
有当7月的时候才会触发,并不是表示每个6月。

L是‘last’的省略写法可以表示day-of-month和day-of-week域,但在两个字段中的意思不同,例如day-of-
month域中表示一个月的最后一天。如果在day-of-week域表示‘7’或者‘SAT’,如果在day-of-week域中前面加上数字,它表示
一个月的最后几天,例如‘6L’就表示一个月的最后一个星期五。

字符“W”只允许日期域出现。这个字符用于指定日期的最近工作日。例如:如果你在日期域中写
“15W”,表示:这个月15号最近的工作日。所以,如果15号是周六,则任务会在14号触发。如果15好是周日,则任务会在周一也就是16号触发。如果
是在日期域填写“1W”即使1号是周六,那么任务也只会在下周一,也就是3号触发,“W”字符指定的最近工作日是不能够跨月份的。字符“W”只能配合一个
单独的数值使用,不能够是一个数字段,如:1-15W是错误的。

“L”和“W”可以在日期域中联合使用,LW表示这个月最后一周的工作日。

字符“#”只允许在星期域中出现。这个字符用于指定本月的某某天。例如:“6#3”表示本月第三周的星期五(6表示星期五,3表示第三周)。“2#1”表示本月第一周的星期一。“4#5”表示第五周的星期三。

字符“C”允许在日期域和星期域出现。这个字符依靠一个指定的“日历”。也就是说这个表达式的值依赖于相关的“日历”的计算结果,如果没有“日历”
关联,则等价于所有包含的“日历”。如:日期域是“5C”表示关联“日历”中第一天,或者这个月开始的第一天的后5天。星期域是“1C”表示关联“日历”
中第一天,或者星期的第一天的后1天,也就是周日的后一天(周一)。

四、表达式举例
"0 0 12 * * ?" 每天中午12点触发
"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点到下午2:59期间的每1分钟触发
"0 0/5 14 * * ?" 在每天下午2点到下午2:55期间的每5分钟触发
"0 0/5 14,18 * * ?" 在每天下午2点到2:55期间和下午6点到6:55期间的每5分钟触发
"0 0-5 14 * * ?" 在每天下午2点到下午2:05期间的每1分钟触发
"0 10,44 14 ? 3 WED" 每年三月的星期三的下午2:10和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年至2005年的每月的最后一个星期五上午10:15触发
"0 15 10 ? * 6#3" 每月的第三个星期五上午10:15触发

spring-定时器(1)的更多相关文章

  1. spring定时器,定时器一次执行两次的问题

    Spring 定时器 方法一:注解形式 配置文件头加上如下: xmlns:task="http://www.springframework.org/schema/task" htt ...

  2. Spring 定时器Quartz的用法

    Spring定时器Quartz的用法也很简单,需要引入quartz-all-1.5.2.jar java代码如下: package com.coalmine.desktop; import java. ...

  3. spring定时器,当遇见半小时的情况时

    spring定时器遇见半小时的解决方法(这里只提供注解方式) @Scheduled(fixedRate=6000000)//每隔100分钟执行方法 fixedRate的值是毫秒

  4. Spring 定时器的使用

    spring定时器应用 相关类: org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean 配置定时远行方法 o ...

  5. spring定时器

    本人小菜鸟一枚,今天在公司看到一段spring定时器配置,自己总结一下! <!-- 定义调用对象和调用对象的方法 --><bean id="jobtask9" c ...

  6. 两种流行Spring定时器配置:Java的Timer类和OpenSymphony的Quartz

    1.Java Timer定时 首先继承java.util.TimerTask类实现run方法 import java.util.TimerTask; public class EmailReportT ...

  7. 注解式开发spring定时器

    1:spring 配置文件中增加这句    <task:annotation-driven/>  2:确保扫描程序能够扫描后  下面第3步骤的java类    <context:co ...

  8. spring定时器设置(转自:http://my.oschina.net/LvSantorini/blog/520049)

    转自:http://my.oschina.net/LvSantorini/blog/520049<!-- MessageRequestTask类中包含了msgRequest方法,用于执行定时任务 ...

  9. spring定时器,5步完成

    spring定时器,5步完成,我们开发的时候会用定时执行任务. 用spring框架时,可以直接使用spring定时功能 1.创建任务调度类,里面一个方法,方法名为work 2. spring配置文件, ...

  10. spring定时器用Annotation兑现

    spring定时器用Annotation实现 0人收藏此文章, 我要收藏发表于3个月前 , 已有46次阅读 共0个评论 1.ApplicationContext.xml配置 a).需要在xmlns里面 ...

随机推荐

  1. android开发之 包含EditText组件 禁止自动获取焦点弹出输入法

    在EditText标签的外层Layout中加入focusableInTouchMode属性   android:focusableInTouchMode="true" 即可.

  2. (iOS)关于zbar扫描条形码,所搭载的设备

    四个月之前写的,现在发出来. 最近在开发一款程序的时候,功能要求扫描条形码. 现在最流行的扫描条形码的开源代码有zbar和zxing两种,可以支持多种一维和二维码. 之前了解过zbar,所以这次试用z ...

  3. TableView cell自适应高度-----xib

    1.通过xib创建一个cell,将label进行上左下右,进行适配, self.automaticallyAdjustsScrollViewInsets = NO; self.edgesForExte ...

  4. Centos7上安装Kubernetes集群部署docker

    一.安装前准备1.操作系统详情需要三台主机,都最小化安装 centos7.3,并update到最新 [root@master ~]# (Core) 角色 主机名 IPMaster master 192 ...

  5. [Linux] PHP程序员玩转Linux系列-使用supervisor实现守护进程

    1.PHP程序员玩转Linux系列-怎么安装使用CentOS 2.PHP程序员玩转Linux系列-lnmp环境的搭建 3.PHP程序员玩转Linux系列-搭建FTP代码开发环境 4.PHP程序员玩转L ...

  6. ios sqlite3的简单使用

    第一:创建表格 //创建表格 -(void)creatTab{ NSString*creatSQL=@"CREATE TABLE IF NOT EXISTS PERSIONFO(ID INT ...

  7. SQL语句简单整理

    转载原文:http://blog.sina.com.cn/s/blog_48df31d901017c6o.html 1.用户 - 查看当前用户的缺省表空间 select username,defaul ...

  8. Spring+SpringMVC+MyBatis+easyUI整合优化篇(十一)数据层优化-druid监控及慢sql记录

    本文提要 前文也提到过druid不仅仅是一个连接池技术,因此在将整合druid到项目中后,这一篇文章将去介绍druid的其他特性和功能,作为一个辅助工具帮助提升项目的性能,本文的重点就是两个字:监控. ...

  9. 【代码学习】PHP 正则表达式

    一.正则表达式介绍 正则表达式是用于描述字符排列和匹配模式的一种规则,主要用于字符串的匹配.查找.替换.分割等操作 ------------------------------------------ ...

  10. 天方夜谈·数据结构·Queue

    "我在想Y的时候不能想X....." 什么叫做Queue(队列)?"队列是项的集合,对于每一项x和y,如果x在y之前离开对头,那么x一定在y之前进入队列--Sesh·Ve ...