首页 Quartz2.1.7学习笔记

Quartz2.1.7学习笔记

举报
开通vip

Quartz2.1.7学习笔记2015年3月10日星期二 1. Quartz简介 Quartz是一个开源的作业调度框架,它完全由Java写成,并设计用于J2SE和J2EE应用中。它提供了巨大的灵活性而不牺牲简单性。你能够用它来为执行一个作业而创建简单的或复杂的调度。它有很多特征,如:数据库支持,集群,插件,EJB作业预构建,JavaMail及其它,支持cron-like表达式等等。 2. 下载说明 3. 如何删除一个job 1.1. 获取运行job的jobKey或者自己声明一个 JobKey job2_key = job2.getKey(...

Quartz2.1.7学习笔记
2015年3月10日星期二 1. Quartz简介 Quartz是一个开源的作业调度框架,它完全由Java写成,并 设计 领导形象设计圆作业设计ao工艺污水处理厂设计附属工程施工组织设计清扫机器人结构设计 用于J2SE和J2EE应用中。它提供了巨大的灵活性而不牺牲简单性。你能够用它来为执行一个作业而创建简单的或复杂的调度。它有很多特征,如:数据库支持,集群,插件,EJB作业预构建,JavaMail及其它,支持cron-like表达式等等。 2. 下载说明 3. 如何删除一个job 1.1. 获取运行job的jobKey或者自己声明一个 JobKey job2_key = job2.getKey(); 或者:JobKey job2_key = new JobKey("job2", "group2"); 1.2. 删除代码 // 删除job2 JobKey job2_key = new JobKey("job2", "group2"); scheduler.deleteJob(job2_key); 1. 触发器 1.2. 简单触发器 1.3. Cron触发器 1.1.1 简介 CronTrigger 支持比 SimpleTrigger 更具体的调度,而且也不是很复杂。基于 cron 表达式,CronTrigger 支持类似日历的重复间隔,而不是单一的时间间隔 —— 这相对 SimpleTrigger 而言是一大改进。 Cron 表达式包括以下 7 个字段: 字段名 允许的值 特殊的值 秒 0-59 , - * / 分 0-59 , - * / 时 0-23 , - * / 日 1-31 , - * / ? L W 月 1-12 或JAN-DEC , - * / 周 1-7 或SUN-SAT , - * / ? L # 年(可选) 空 或 1970-2199 , - * /       说明: 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 fields, but not the other. 翻译:问号’?’只能用在日和周的字段中,用来指定“没有特定的值”。当你要指定两个字段中的一个字段为特殊日期,而另外一个不是,特别有用。 注:日和周的字段必须有一个为’?’,不然会出现异常。 CronExpression '0/20 * * * * *' is invalid,. Caused by: java.text.ParseException: Support for specifying both a day-of-week AND a day-of-month parameter is not implemented. The '-' character is used to specify ranges. For example "10-12" in the hour field means "the hours 10, 11 and 12". 翻译:横’-’表示范围。 例如,在小时字段中”10-12”表示”10,11和12”3个时间。 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. 翻译:斜杠’/’用来表示递增值。例如,在秒字段中”0/15”表示”0秒,15秒,30秒,45秒”。又,在秒字段中”5/15”表示”5秒,20秒,35秒,50秒”。 在”/”前使用”*”和使用”0”的效果一样。 需要注意的是,在每一个字段中,值的范围可能超出。对于秒和分钟,值的范围是0到59,小时范围是0到23,天是0到31(估计这个地方英文有错),月是1到12。”/”能很简单第指定”第几”值。例如在月中指定”7/6”表示7月,而不是每6个月,请注意这一点。 注: 关于最后一点再记一点,例如 "40/30 * * * * ?" 运行的结果: SimpleJob says: group1.job1 executing at Tue Mar 10 10:59:40 CST 2015 SimpleJob says: group1.job1 executing at Tue Mar 10 11:00:40 CST 2015 SimpleJob says: group1.job1 executing at Tue Mar 10 11:01:40 CST 2015 对于这一点写法最好写成 “n/范围最大值”,例如”40/59”,当然也可以直接写个“40”,这样最简单。 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". You can also specify an offset from the last day of the month, such as "L-3" which would mean the third-to-last day of the calendar month. When using the 'L' option, it is important not to specify lists, or ranges of values, as you'll get confusing/unexpected results. 翻译:字符”L”只能用在日和周字段中。该字符是”last”的简写,但是在这两个字段中表示的意思是不一样的。 例如,在日字段中表示月的最后一天---1月是31日,2月是28日(不是闰年)。 如果在周字段中单独用“L”的话,仅仅表示“7”或者“星期六”。 如果在周字段中和别的值一起用,表示“一个月中最后一个星期几”----例如“6L”表示“一个月中最后一个星期五”。 在日字段中叶可以用来设定月最后一天的前几天的偏移量,例如”L-3”表示一个月中倒数第三天。 L这个选项,不依赖一个特定的值,但是会得到一个令人捉摸不定的值。 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.
本文档为【Quartz2.1.7学习笔记】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
is_531654
暂无简介~
格式:doc
大小:28KB
软件:Word
页数:0
分类:互联网
上传时间:2019-06-14
浏览量:3