转载 2006年05月19日 11:23:00


    <bean id="methodInvokingJobDetail"
        <property name="targetObject"><ref bean="financeDAO"/></property>
        <property name="targetMethod"><value>confirmOrder</value></property>

    <bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
        <property name="jobDetail">
            <ref bean="methodInvokingJobDetail"/>
        <property name="cronExpression">
            <value>0 0 6,12,20 * * ?</value>
    <bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
        <property name="triggers">
            <list><ref local="cronTrigger"/></list>



字段   允许值   允许的特殊字符
  0-59   , - * /
  0-59   , - * /
小时   0-23   , - * /
日期   1-31   , - * ? / L W C
月份   1-12 或者 JAN-DEC   , - * /
星期   1-7 或者 SUN-SAT   , - * ? / L C #
年(可选)   留空, 1970-2099   , - * /

The '*' character is used to specify all values. For example, "*" in the minute field means "every minute".
The '?' character is allowed for the day-of-month and day-of-week fields. It is used to specify 'no specific value'. This is useful when you need to specify something in one of the two fileds, but not the other. See the examples below for clarification.
The '-' character is used to specify ranges For example "10-12" in the hour field means "the hours 10, 11 and 12".
The ',' character is used to specify additional values. For example "MON,WED,FRI" in the day-of-week field means "the days Monday, Wednesday, and Friday".
The '/' character is used to specify increments. For example "0/15" in the seconds field means "the seconds 0, 15, 30, and 45". And "5/15" in the seconds field means "the seconds 5, 20, 35, and 50". Specifying '*' before the '/' is equivalent to specifying 0 is the value to start with. Essentially, for each field in the expression, there is a set of numbers that can be turned on or off. For seconds and minutes, the numbers range from 0 to 59. For hours 0 to 23, for days of the month 0 to 31, and for months 1 to 12. The "/" character simply helps you turn on every "nth" value in the given set. Thus "7/6" in the month field only turns on month "7", it does NOT mean every 6th month, please note that subtlety.
The 'L' character is allowed for the day-of-month and day-of-week fields. This character is short-hand for "last", but it has different meaning in each of the two fields. For example, the value "L" in the day-of-month field means "the last day of the month" - day 31 for January, day 28 for February on non-leap years. If used in the day-of-week field by itself, it simply means "7" or "SAT". But if used in the day-of-week field after another value, it means "the last xxx day of the month" - for example "6L" means "the last friday of the month". When using the 'L' option, it is important not to specify lists, or ranges of values, as you'll get confusing results.
The 'W' character is allowed for the day-of-month field. This character is used to specify the weekday (Monday-Friday) nearest the given day. As an example, if you were to specify "15W" as the value for the day-of-month field, the meaning is: "the nearest weekday to the 15th of the month". So if the 15th is a Saturday, the trigger will fire on Friday the 14th. If the 15th is a Sunday, the trigger will fire on Monday the 16th. If the 15th is a Tuesday, then it will fire on Tuesday the 15th. However if you specify "1W" as the value for day-of-month, and the 1st is a Saturday, the trigger will fire on Monday the 3rd, as it will not 'jump' over the boundary of a month's days. The 'W' character can only be specified when the day-of-month is a single day, not a range or list of days.
The 'L' and 'W' characters can also be combined for the day-of-month expression to yield 'LW', which translates to "last weekday of the month".
The '#' character is allowed for the day-of-week field. This character is used to specify "the nth" XXX day of the month. For example, the value of "6#3" in the day-of-week field means the third Friday of the month (day 6 = Friday and "#3" = the 3rd one in the month). Other examples: "2#1" = the first Monday of the month and "4#5" = the fifth Wednesday of the month. Note that if you specify "#5" and there is not 5 of the given day-of-week in the month, then no firing will occur that month.
The 'C' character is allowed for the day-of-month and day-of-week fields. This character is short-hand for "calendar". This means values are calculated against the associated calendar, if any. If no calendar is associated, then it is equivalent to having an all-inclusive calendar. A value of "5C" in the day-of-month field means "the first day included by the calendar on or after the 5th". A value of "1C" in the day-of-week field means "the first day included by the calendar on or after sunday".



What is Quartz? (什么是Quartz?)

What is Quartz? (什么是Quartz?)
Quartz is a full-featured, open source job scheduling system that can be integrated with, or used along side virtually any J2EE or J2SE application - from the smallest stand-alone application to the largest e-commerce system. Quartz can be used to create simple or complex schedules for executing tens, hundreds, or even tens-of-thousands of jobs; jobs whose tasks are defined as standard Java components or EJBs. The Quartz Scheduler includes many enterprise-class features, such as JTA transactions and clustering.

Quartz 是一个功能齐全的、开源的job时间调度系统,它可以被结合的,或者伴随虚拟的任何J2EE或J2SE程序-从最小的独立的应用程序到最大的e-commerce系统被使用。Quartz可以用来创建简单或复杂的时间调度来执行十、百、千、甚至上万的jobs;获得的job被定义为一个标准的java组件或EJBs. 这个Quartz 时间调度包含很多企业类的特征,例如JTA事务和簇。

The licensing of Quartz versions 1.0 through 1.4.5 is similar to both the BSD and ASF (Apache) public licenses, which means it's free for use, even within commercial products.

Quartz 1.0版本到1.4.5版本的licensing 是类似与BSD和ASF(apache)公共licenses, 它意味着可以免费使用,甚至使用在商业产品中使用。
With the upcoming release of version 1.5.0, Quartz is moving to the Apache 2.0 license.
伴随1.5.0版本的发布,Quartz将转移向apache 2.0 的license.

What can Quartz do for you? (Quartz可以为你做什么?)
If your application has tasks that need to occur at given moments in time, or if your system has recurring maintenance jobs then Quartz may be your ideal solution.


Sample uses of job scheduling with Quartz:

Driving Workflow: As a new order is initially placed, schedule a Job to fire in exactly 2 hours, that will check the status of that order, and trigger a warning notification if an order confirmation message has not yet been received for the order, as well as changing the order's status to 'awaiting intervention'.
System Maintenance: Schedule a job to dump the contents of a database into an XML file every business day (all weekdays except holidays) at 11:30 PM.

系统维护:调度一个job来将数据库转化为XML文件 每商业日期(所有周末除了节假日)在下午11:30。


  • chenleixing
  • chenleixing
  • 2015年01月30日 23:42
  • 5209


  • chenleixing
  • chenleixing
  • 2015年01月30日 23:22
  • 2403

Spring quartz定时任务Service注入问题

  • u012385190
  • u012385190
  • 2016年11月25日 10:16
  • 3606


使用xml配置Quartz,实现定时任务使用xml配置前景以前我是使用java代码配置Quartz任务的,到最好你会发现,这个类使用其他类成员变量会无法自动注入问题 始终是空指针问题,到最后只能手动...
  • JarremDon
  • JarremDon
  • 2017年12月12日 11:00
  • 68


可以说是最好的一篇定时任务的介绍 来自:http://www.zuidaima.com/share/2736623139458048.htm 一.代码结构图 二.核心类 J...
  • u013380777
  • u013380777
  • 2017年01月09日 12:33
  • 329


Quartz介绍: Quartz是OpenSymphony开源组织在Job scheduling领域又一个开源项目,它可以与J2EE与J2SE应用程序相结合也可以单独使用。Quartz可以用来创建简单...
  • u013310119
  • u013310119
  • 2017年04月01日 10:01
  • 5698

6. springboot整合quartz实现定时任务

转载:http://www.cnblogs.com/lic309/p/4089633.html 在做项目时有时候会有定时器任务的功能,比如某某时间应该做什么,多少秒应该怎么样...
  • LINABC123000
  • LINABC123000
  • 2017年04月04日 11:55
  • 487


本篇博文主要是讲述2.x 版本的quartz下的实现方案,1.x 版本的实现方式大致原理一致,但是具体的实现方式有些不一致,具体体现在获取  scheduler 这个类的方式上有些不同,这里不作过多的...
  • w405722907
  • w405722907
  • 2017年05月18日 10:06
  • 843


实现定时任务:quartz spring中对quartz进行了封装,使得我们可以直接在配置文件中配置bean就可以使用quartz的定时任务 首先在spring中使用quartz需要引入的包: ...
  • qq_18675693
  • qq_18675693
  • 2015年12月27日 20:34
  • 1951


一、Quartz简介  Quartz大致可分为三个主要的核心:     1、调度器Scheduler:是一个计划调度器容器,容器里面可以盛放众多的JobDetail和Trigger,当容器...
  • liuxiao723846
  • liuxiao723846
  • 2015年07月14日 16:10
  • 2392