<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    Oracle神諭

      BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
      284 隨筆 :: 9 文章 :: 106 評(píng)論 :: 0 Trackbacks
     定時(shí)批處理作業(yè)是J2EE企業(yè)應(yīng)用里很重要的一環(huán),用來在晚間進(jìn)行財(cái)務(wù)掛賬,數(shù)據(jù)轉(zhuǎn)存,新聞聯(lián)播等等操作。

        而在Spring里,已經(jīng)很好的集成了Quartz,簡單到像配cron一樣,在xml文件里面配一下時(shí)間就可以自動(dòng)執(zhí)行,不需要寫一行代碼。Spring對Quartz大刀闊斧的簡化堪稱范例,Quartz項(xiàng)目組也許可以學(xué)習(xí)一下。

        <bean id="methodInvokingJobDetail"
            class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
            <property name="targetObject"><ref bean="financeDAO"/></property>
            <property name="targetMethod"><value>confirmOrder</value></property>
        </bean>

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

    上面這段配置文件規(guī)定了在早上6點(diǎn)和晚上8點(diǎn)執(zhí)行financeDAO對象的confirmOrder()方法.


    附:cronExpression配置說明

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

    posted on 2005-07-20 21:37 java世界暢談 閱讀(15603) 評(píng)論(42)  編輯  收藏 所屬分類: Spring

    評(píng)論

    # re: Spring--簡單使用quartz實(shí)現(xiàn)定時(shí)作業(yè) 2005-11-06 18:41 else
    這么多人看了這篇日志,竟然沒人回復(fù),太不厚道了,看來都是google過來的
    花了不短的時(shí)間仔細(xì)研究了quartz的內(nèi)部代碼
    才發(fā)現(xiàn)spring都已經(jīng)把事情做完了,sigh  回復(fù)  更多評(píng)論
      

    # re: Spring--簡單使用quartz實(shí)現(xiàn)定時(shí)作業(yè) 2005-11-08 11:57 wtigter
    不錯(cuò),允許的特殊字符,包括那些東西。  回復(fù)  更多評(píng)論
      

    # re: Spring--簡單使用quartz實(shí)現(xiàn)定時(shí)作業(yè) 2005-11-08 11:58 wtigter
    能解釋下后面的字符的用法嗎?
    wtigter@163.com  回復(fù)  更多評(píng)論
      

    # re: Spring--簡單使用quartz實(shí)現(xiàn)定時(shí)作業(yè) 2005-11-08 12:04 wtigter
    <property name="cronExpression">
    <value>0 0 6,12,20 * * ?</value>
    </property>

    這里是6,12,20,怎么你說是定時(shí)在
    在早上6點(diǎn)和晚上8點(diǎn)執(zhí)行

    那12點(diǎn)不執(zhí)行嗎  回復(fù)  更多評(píng)論
      

    # re: Spring--簡單使用quartz實(shí)現(xiàn)定時(shí)作業(yè) 2005-11-08 14:12 wtigter
    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.
    “?”字符只在日期域和星期域中使用。它被用來指定“非明確的值”。當(dāng)你需要通過在這兩個(gè)域中的一個(gè)來指定一些東西的時(shí)候,它是有用的。看下面的例子你就會(huì)明白。
    The '-' character is used to specify ranges For example "10-12" in the hour field means "the hours 10, 11 and 12".
    “-”字符被用來指定一個(gè)范圍。如:“10-12”在小時(shí)域意味著“10點(diǎn)、11點(diǎn)、12點(diǎn)”。
    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".
    “,”字符被用來指定另外的值。如:“MON,WED,FRI”在星期域里表示”星期一、星期三、星期五”.
    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".
      回復(fù)  更多評(píng)論
      

    # re: Spring--簡單使用quartz實(shí)現(xiàn)定時(shí)作業(yè) 2005-11-19 10:30 kcb
    請問,如果所執(zhí)行的方法需要用戶提供參數(shù)應(yīng)該怎么做?謝謝!  回復(fù)  更多評(píng)論
      

    # re: Spring--簡單使用quartz實(shí)現(xiàn)定時(shí)作業(yè) 2005-12-14 10:42 丫梨
    嗨,那你能不能告訴我,如何在服務(wù)器啟動(dòng)的時(shí)候就調(diào)用某個(gè)類中的一個(gè)方法呢?我想這個(gè)方法只在服務(wù)器啟動(dòng)的時(shí)候才調(diào)用一次。如果你知道的話,請告訴我哦,我的郵箱是wjljava@163.com,真的是非常感謝!  回復(fù)  更多評(píng)論
      

    # re: Spring--簡單使用quartz實(shí)現(xiàn)定時(shí)作業(yè) 2005-12-14 23:37 jon
    我也用這個(gè),配置的是<property name="cronExpression">
    <value>0 0 3 * * ?</value>
    </property>早上3點(diǎn)運(yùn)行,在TOMCAT下能很好啟動(dòng)一次任務(wù),而在SUNONE服務(wù)器下,會(huì)同時(shí)啟動(dòng)兩個(gè)定時(shí)任務(wù),真奇怪,搞得插入記錄總是重復(fù),且重復(fù)生成的時(shí)間只相差幾秒而已,有哪位知道呀?  回復(fù)  更多評(píng)論
      

    # re: Spring--簡單使用quartz實(shí)現(xiàn)定時(shí)作業(yè) 2005-12-14 23:38 jon
    我的EMAIL:jon.xiong@163.com  回復(fù)  更多評(píng)論
      

    # re: Spring--簡單使用quartz實(shí)現(xiàn)定時(shí)作業(yè) 2006-03-08 15:19 klt8848
    好東東!  回復(fù)  更多評(píng)論
      

    # re: Spring--簡單使用quartz實(shí)現(xiàn)定時(shí)作業(yè) 2006-04-03 10:14 avgi
    @丫梨
    可以在spring初始化bean時(shí)做點(diǎn)手腳。  回復(fù)  更多評(píng)論
      

    # re: Spring--簡單使用quartz實(shí)現(xiàn)定時(shí)作業(yè) 2006-05-18 10:32 對沖
    @kcb
    @wtigter
    應(yīng)該執(zhí)行吧,估計(jì)是少寫了  回復(fù)  更多評(píng)論
      

    # re: Spring--簡單使用quartz實(shí)現(xiàn)定時(shí)作業(yè) 2006-06-21 14:59 frankie
    好東西!為了避免被說不厚道,嘿嘿
      回復(fù)  更多評(píng)論
      

    # re: Spring--簡單使用quartz實(shí)現(xiàn)定時(shí)作業(yè) 2006-07-31 17:58 長征路上的妖怪
    有人用quartz嗎?CronTrigger中的若干個(gè)構(gòu)造方法中的String類型是什么用處呢?  回復(fù)  更多評(píng)論
      

    # re: Spring--簡單使用quartz實(shí)現(xiàn)定時(shí)作業(yè) 2006-08-03 17:11 flyhawk1010
    好文!正好項(xiàng)目要用到!  回復(fù)  更多評(píng)論
      

    # re: Spring--簡單使用quartz實(shí)現(xiàn)定時(shí)作業(yè) 2006-08-04 10:28 潘曉歡
    financeDAO對象怎么建立,能不能給完整點(diǎn)
    ÷  回復(fù)  更多評(píng)論
      

    # re: Spring--簡單使用quartz實(shí)現(xiàn)定時(shí)作業(yè) 2006-08-04 12:51 terry0431
    怎樣實(shí)現(xiàn)動(dòng)態(tài)設(shè)置任務(wù)?不重起服務(wù)  回復(fù)  更多評(píng)論
      

    # re: Spring--簡單使用quartz實(shí)現(xiàn)定時(shí)作業(yè) 2006-08-10 14:04 kevin.guo
    quartz的高級(jí)特性不僅如此
    1 數(shù)據(jù)庫存儲(chǔ)
    2 集群支持
    3 數(shù)據(jù)庫持久化任務(wù),trigger
    4 trigger 的停止,運(yùn)行
    5 任務(wù)的任意添加
    6 比corntrigger 更詳盡的任務(wù)安排
    7 線程的內(nèi)部數(shù)據(jù)交換  回復(fù)  更多評(píng)論
      

    # re: Spring--簡單使用quartz實(shí)現(xiàn)定時(shí)作業(yè) 2006-09-11 15:14 gLaiVe
    @kevin.guo

    你說的trigger的停止,能不能動(dòng)態(tài)設(shè)置的呢,比如我想在任何時(shí)刻停止當(dāng)前正在跑得task,我現(xiàn)在的quartz是配置在spring里面了,怎么用spring來控制  回復(fù)  更多評(píng)論
      

    # re: Spring--簡單使用quartz實(shí)現(xiàn)定時(shí)作業(yè) 2006-09-16 18:05 xiaqingfeng
    為什么我照你的寫會(huì)出一個(gè)異常
    Failure obtaining db row lock: Table 'onhave.qrtz_locks' doesn't exist [See nested exception: java.sql.SQLException: Table 'onhave.qrtz_locks' doesn't exist]  回復(fù)  更多評(píng)論
      

    # re: Spring--簡單使用quartz實(shí)現(xiàn)定時(shí)作業(yè) 2006-09-18 22:39 xiaqingfeng
    請高手指點(diǎn)一下啊,為什么會(huì)報(bào)異常?難道一定要建表嗎?可我不想建表  回復(fù)  更多評(píng)論
      

    # re: Spring--簡單使用quartz實(shí)現(xiàn)定時(shí)作業(yè) 2006-11-03 18:25 kevin.guo
    你說的trigger的停止,能不能動(dòng)態(tài)設(shè)置的呢,

    我沒用spring集成,做法是job里調(diào)用trigger的停方法,這樣trigger驅(qū)動(dòng)的job都不會(huì)被執(zhí)行了  回復(fù)  更多評(píng)論
      

    # re: Spring--簡單使用quartz實(shí)現(xiàn)定時(shí)作業(yè) 2007-03-21 16:29 helloint
    cronExpression配置說明

    這個(gè)說的太簡單拉..  回復(fù)  更多評(píng)論
      

    # re: Spring--簡單使用quartz實(shí)現(xiàn)定時(shí)作業(yè) 2007-04-10 11:08 houhy
    一個(gè)cron表達(dá)式有至少6個(gè)(也可能是7個(gè))由空格分隔的時(shí)間元素。從左至右,這些元素的定義如下:

    1.秒(0–59)

    2.分鐘(0–59)

    3.小時(shí)(0–23)

    4.月份中的日期(1–31)

    5.月份(1–12或JAN–DEC)

    6.星期中的日期(1–7或SUN–SAT)

    7.年份(1970–2099)  回復(fù)  更多評(píng)論
      

    # re: Spring--簡單使用quartz實(shí)現(xiàn)定時(shí)作業(yè) 2007-11-06 18:14 fenix
    好  回復(fù)  更多評(píng)論
      

    # re:sss 2007-11-26 10:13 dfsf
    Good java spring   回復(fù)  更多評(píng)論
      

    # re: Spring--簡單使用quartz實(shí)現(xiàn)定時(shí)作業(yè) 2007-11-28 14:32 meizi
    真棒!!  回復(fù)  更多評(píng)論
      

    # re: Spring--簡單使用quartz實(shí)現(xiàn)定時(shí)作業(yè) 2008-01-02 23:01 linuxboy
    VERY good!  回復(fù)  更多評(píng)論
      

    # re: Spring--簡單使用quartz實(shí)現(xiàn)定時(shí)作業(yè) 2008-01-09 15:54 quarts
    多謝樓主,不錯(cuò)的文章。我通過你的文章配置了Quarts的應(yīng)用,但在tomcat上使用時(shí),出現(xiàn)過只能采集一次,之后那線程一直阻塞狀態(tài)沒法定時(shí)下去,該怎么辦?  回復(fù)  更多評(píng)論
      

    # re: Spring--簡單使用quartz實(shí)現(xiàn)定時(shí)作業(yè) [未登錄] 2008-01-21 12:28 leo
    up 。。。。。。。。。  回復(fù)  更多評(píng)論
      

    # re: Spring--簡單使用quartz實(shí)現(xiàn)定時(shí)作業(yè) 2008-01-28 10:07 df
    good  回復(fù)  更多評(píng)論
      

    # re: Spring--簡單使用quartz實(shí)現(xiàn)定時(shí)作業(yè) [未登錄] 2008-03-30 09:29 aa
    good
      回復(fù)  更多評(píng)論
      

    # re: Spring--簡單使用quartz實(shí)現(xiàn)定時(shí)作業(yè) 2008-04-11 13:34 初級(jí)
    <bean id="fileWriteTrigger1" class="org.springframework.scheduling.quartz.CronTriggerBean">
    <property name="jobDetail">
    <ref bean="fileWriteDetail"/>
    </property>
    <property name="cronExpression">
    <value>0 27 10 ? * *</value>
    </property>
    </bean>
    這個(gè)job執(zhí)行了一次,我修改為“<value>0 27 13 ? * *</value>”就不再自動(dòng)執(zhí)行,再改為其他時(shí)間,也不再自動(dòng)執(zhí)行。我重啟服務(wù)也沒用。誰遇見到這個(gè)問題啊?  回復(fù)  更多評(píng)論
      

    # re: Spring--簡單使用quartz實(shí)現(xiàn)定時(shí)作業(yè) 2008-05-19 09:30 asd
    不錯(cuò),學(xué)習(xí)了。  回復(fù)  更多評(píng)論
      

    # re: Spring--簡單使用quartz實(shí)現(xiàn)定時(shí)作業(yè) 2008-07-18 16:37 zlj
    學(xué)習(xí)中。。。  回復(fù)  更多評(píng)論
      

    # re: Spring--簡單使用quartz實(shí)現(xiàn)定時(shí)作業(yè) 2008-07-30 18:03 飛越海面
    我想請問一下對于現(xiàn)在的spring中集成的還是這樣的配置方式嗎?  回復(fù)  更多評(píng)論
      

    # re: Spring--簡單使用quartz實(shí)現(xiàn)定時(shí)作業(yè) 2008-07-31 15:26 black_boy
    太好了,解了我燃眉之急  回復(fù)  更多評(píng)論
      

    # re: Spring--簡單使用quartz實(shí)現(xiàn)定時(shí)作業(yè) [未登錄] 2008-08-24 13:51 wz
    正要用這個(gè),好啊,謝謝!  回復(fù)  更多評(píng)論
      

    # re: Spring--簡單使用quartz實(shí)現(xiàn)定時(shí)作業(yè) 2008-10-27 16:00 9527
    為什么我跟你寫的一樣 但是我的TOMCAT啟動(dòng)之后 沒有反應(yīng)呢?請高手指點(diǎn) 多謝啦  回復(fù)  更多評(píng)論
      

    # re: Spring--簡單使用quartz實(shí)現(xiàn)定時(shí)作業(yè) 2009-01-13 22:14 odin
    真慶幸可以看到你的文章,對我太有幫助了!  回復(fù)  更多評(píng)論
      

    # re: Spring--簡單使用quartz實(shí)現(xiàn)定時(shí)作業(yè) 2009-10-19 14:34 coding
    不錯(cuò) 很有幫助 學(xué)習(xí)了  回復(fù)  更多評(píng)論
      

    # re: Spring--簡單使用quartz實(shí)現(xiàn)定時(shí)作業(yè) 2009-12-04 19:35 baizhiguo
    我的配置文件和你的一樣但是就是報(bào)錯(cuò):錯(cuò)誤內(nèi)容是找不到:org.springframework.scheduling.quartz.CronTriggerBean,那個(gè)包也有了  回復(fù)  更多評(píng)論
      

    主站蜘蛛池模板: 亚洲国产欧美日韩精品一区二区三区| 亚洲精品中文字幕麻豆| 日本亚洲欧洲免费天堂午夜看片女人员| 亚洲国产精品无码一线岛国| 亚洲A∨无码无在线观看| 亚洲国产亚洲片在线观看播放 | 亚洲一卡二卡三卡四卡无卡麻豆| 亚洲永久网址在线观看| 美女视频黄a视频全免费网站一区| 久久www免费人成精品香蕉| 小草在线看片免费人成视久网| 亚洲免费在线视频观看| 色吊丝最新永久免费观看网站 | 欧洲亚洲国产清在高| 亚洲精品在线播放视频| 久久精品国产亚洲AV未满十八| aa在线免费观看| 国产成人精品免费视频动漫 | 亚洲熟伦熟女专区hd高清| 免费精品国产自产拍在线观看| 嫩草在线视频www免费观看| 日韩精品无码区免费专区 | 国产男女猛烈无遮挡免费视频| 亚洲精品~无码抽插| 亚洲欧洲日韩国产一区二区三区| 特a级免费高清黄色片| 99在线观看精品免费99| 国产乱色精品成人免费视频| 亚洲AV第一页国产精品| 亚洲国产精品成人综合色在线| 免费看无码特级毛片| 永久免费AV无码网站在线观看| 亚洲国产成人片在线观看无码 | 成人免费毛片观看| 亚洲精品成人无码中文毛片不卡| 亚洲性线免费观看视频成熟| 视频免费在线观看| 国产在线19禁免费观看| 97久久精品亚洲中文字幕无码| 日韩在线一区二区三区免费视频| 无人在线直播免费观看|