- 浏览: 47193 次
- 性别:
- 来自: 未来
文章分类
最新评论
-
lurenjiaxxy:
我这边测下来可是StringUtils比较快,StringUt ...
apache的replace,trim方法 StringUtils.replace(),StringUtils.trimWhitespace() java原生 -
cgddm:
...
apache的replace,trim方法 StringUtils.replace(),StringUtils.trimWhitespace() java原生
ava服务自带了定时服务Timer,不过我在研究spring,所以就使用了quartz,因为spring良好的支持了quartz,使用起来还是相当的简单
- <!-- 实现规则服务实时加载的定时服务配置文件 -->
- <beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:aop="http://www.springframework.org/schema/aop"
- xmlns:tx="http://www.springframework.org/schema/tx"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
- http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
- http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
- <bean id="loadObject" class="com.sunyard.rule.global.ContextLoad"/>
- <bean name="jobDetailBean" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
- <property name="targetObject" ref="loadObject"/>
- <property name="targetMethod" value="load"/>
- </bean>
- <bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
- <property name="jobDetail">
- <ref bean="jobDetailBean" />
- </property>
- <!--
- 下面表示每天晚上21点执行
- 配置具体方法见《定时服务配置说明》
- -->
- <property name="cronExpression">
- <value>0 0 21 * * ?</value>
- </property>
- </bean>
- <bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
- <property name="triggers">
- <list>
- <ref bean="cronTrigger" />
- </list>
- </property>
- </bean>
- </beans>
id="loadObject"是定时服务类;
name="jobDetailBean"用来指定定时服务的方法;
id="cronTrigger"配置定时服务的时间;
最后一个bean用来设置定时服务队列。
(解释比较直白)
下面介绍一下定时服务时间的配置,也可以为以后做备忘:
表达式意义:
秒 0-59 , - * /
分 0-59 , - * /
小时 0-23 , - * /
日期 1-31 , - * ? / L W C
月份 1-12 或者 JAN-DEC , - * /
星期 1-7 或者 SUN-SAT , - * ? / L C #
年(可选) 留空, 1970-2099 , - * /
例子:
"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触发
每天早上6点
0 6 * * *
每两个小时
0 */2 * * *
晚上11点到早上8点之间每两个小时,早上八点
0 23-7/2,8 * * *
每个月的4号和每个礼拜的礼拜一到礼拜三的早上11点
0 11 4 * 1-3
1月1日早上4点
0 4 1 1 *
特殊字符说明:
"*"字符被用来指定所有的值。如:"*"在分钟的字段域里表示"每分钟"。
"?"字符只在日期域和星期域中使用。它被用来指定"非明确的值"。当你需要通过在这两个域中的一个来指定一些东西的时候,它是有用的。
月份中的日期和星期中的日期这两个元素时互斥的一起应该通过设置一个问号(?)来表明不想设置那个字段
"-"字符被用来指定一个范围。如:"10-12"在小时域意味着"10点、11点、12点"。
","字符被用来指定另外的值。如:"MON,WED,FRI"在星期域里表示"星期一、星期三、星期五".
"/"字符用来指定具体的增量。如"0/15"在秒中的配置表示"从0秒开始每隔15秒",即"0,15,30,45"。
如"5/15"在秒中的配置表示"从5秒开始每隔15秒",即"5,20,35,50"。"*/5"和"0/5"是一个效果。
L是‘last’的省略写法可以表示day-of-month和day-of-week域,但在两个字段中的意思不同,
例如day-of-month域中表示一个月的最后一天, 如果在day-of-week域表示‘7’或者‘SAT’,
如果在day-of-week域中前面加上数字,它表示一个月的最后几天,例如‘6L’就表示一个月的最后一个星期五。
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".
发表评论
-
Spring JMS 整合Tomcat和ActiveMQ
2012-03-15 14:45 13281.Active MQ安装配置 1.1.下载并解压Active ... -
java 动态添加方法和属性
2012-02-27 17:07 0Java字节码操纵框架 :ASM 和 javassist -
oracle的体系
2012-02-03 13:41 692一:oracle体系 oracle的体系很庞大,要学习它,首 ... -
oracle数据备份
2012-02-02 13:52 729ORACLE 备份三种方法: 1. imp(导入),e ... -
项目预警管理
2012-02-01 15:39 66210个项目死亡的信号:(1)第一版做太多功能;(2)太依赖新技 ... -
spring视频
2012-01-13 16:55 0http://www.verycd.com/topics/93 ... -
不错的架构选择
2012-01-07 11:36 0我心目中最好的框架组合是: 表示层:spring mv ... -
JAVA学习之路
2011-12-12 15:49 722JAVA是一种平台,也是一 ... -
ORACLE函数大全
2011-12-09 18:05 671SQL中的单记录函数1.ASCII返回与指定的字符对应的十 ... -
职位要求
2011-12-08 09:24 0架构师 职位描述: 1、 发展应用开发框架和开发工具 ... -
其他一些东西
2011-12-07 15:09 0解压:tar Zxvf FileName.tar.Z ... -
oracle解决死锁
2011-11-28 14:49 760--第一步:查看是否有死锁存在,查出有数据则代表有死锁 s ... -
oracle 字符串加密算法
2011-11-28 11:34 22151、方法一 MD5加密 Java代码 ... -
JAVA程序员的25个标准
2011-11-26 15:52 7771) 你需要精通面向对象分析与设计(OOA/O ... -
逆波兰表达式
2011-11-22 15:38 762逆波兰表达式逆波兰表达式又叫做后缀表达式。在通常的表达式中 ... -
计算机试题
2011-11-22 00:09 729一、选择题(每题1.5分 ... -
程序员做业余项目
2011-11-17 23:17 0编程是一种创造过程,业余项目允许程序员在没有截止日期或各 ... -
各种框架
2011-11-17 23:00 0restlet框架(Restlet项目为“建立REST概念与J ... -
仿百度文库
2011-11-16 15:13 869前向公司有个业务需求,是关于ISO的文件管理! 客户的要求:跟 ... -
几本有用的电子书
2011-11-16 14:35 749一下几个电子书,相信对初学者绝对有帮助,有兴趣的朋友可以去 ...
相关推荐
quartz时间配置表达式生成工具,通界面配置生成表达式
quartz定时任务的cron表达式配置的详细说明,以及一些具体示例。
Springboot整合Quartz实现定时任务数据库动态配置,新增任务、修改cron表达式、暂停任务、恢复任务、删除任务等操作
-- 调用频率设置 每天上午2点和下午5点 cron表达式 --> <bean id="runTime" class="org.springframework.scheduling.quartz.CronTriggerBean"> <value>0 0 2,17 * * ? <!-- 最终启动的配置...
quartz表达式,可直接解压,使用java本地运行即可查看,编辑表达式,方便定时任务一目了然查看。cron表达式用于配置cronTrigger的实例。cron表达式实际上是由七个子表达式组成。这些表达式之间用空格分隔。
0 0 12 * * ? 每天12点运行 0 15 10 ? * * 每天10:15运行 0 15 10 * * ? 每天10:15运行 0 15 10 * * ? * 每天10:15运行 0 15 10 * * ? 2008 在2008年的每天10:15运行 0 * 14 * * ? 每天14点到15点之间每分钟运行一...
通过数据表配置service方法类以及cron表达式,实现quartz定时轮询执行
应用 JobInitializationPlugin 在 quartz_jobs.xml 配置文件中写 Cron 表达式。 第五章. Cron 触发器及相关内容 (第四部分) 内容提要:Cron 表达式 Cookbook,列举了各种 Cron 表达式的写法和意义,有助于更好的...
基于SpringBoot+Quartz的轻量级分布式定时任务调度系统源码+项目说明+sql数据库.zip 主要技术选型 1、后端: - SpringBoot 2.6.11 - Quartz 2.3.2 - Mybatis-Plus 3.5.3.2 - Httpclient 4.5.13 2、前端: - Layui ...
Spring+quartz 一个简单的 定时任务的例子,希望能对大家的学习有帮助。 最后,附:cronExpression配置说明 字段 允许值 允许的特殊字符 秒 0-59 , - * / 分 0-59 , - * / 小时 0-23 , - * / 日期 1-31 , - *...
基于 ADF 框架 + Quartz框架 开发的一套界面可操作的作业调度程序。 界面: 1. 输入:支持 cron表达式; 2. 支持定时调用服务; 3. 支持定时调用数据库脚本(存储过程等); 4. 界面可以查看当前运行的后台作业; 5....
spring定时任务 ...-- 关键在配置此表达式 --> <value>0 49 15 * * ? <bean id="scheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean"> </beans>
前者用于实现比较简单的定时功能,例如几点开始,几 点结束,隔多长时间执行,共执行多少次等,后者提供了使用表达式来描述定时功能,因此适用于比较复杂的定时描述,例如每个月的最后一个周五,每周的周四 等。...
quartz表达式,可直接解压,使用java本地运行即可查看,编辑表达式,方便定时任务一目了然查看。cron表达式用于配置cronTrigger的实例。cron表达式实际上是由七个子表达式组成。这些表达式之间用空格分隔。
9.Quartz的定时调度是怎么实现的?定时调度流程? Wait、notify 实现job类,设置触发器 放到调度器中 start 10.Springboot是怎么整合quartz的? 11.Rides的几种数据类型及应用场景? 12.工作流 activety? 13.禅道...
强自定义:支持在线配置定时任务请求类型、请求路径、请求参数、Cron表达式,即时生效; 动态控制:支持动态修改任务状态、启动/停止任务,以及终止运行中任务,即时生效; 执行策略:支持丰富的执行策略,包括:Get...
将@Scheduled注解与方法一起使用,指定任务执行的时间表达式。 2.使用Spring的TaskScheduler: Spring提供了TaskScheduler接口和相关实现,用于任务调度。使用TaskScheduler,你可以创建计划执行、定期执行或延迟...
我没有用过Linux的cron,但网上说Linux也是可以用crontab -e 命令来配置定时任务。Go语言和Java中都是可以精确到秒的,但是Linux中不行。 cron表达式代表一个时间的集合,使用6个空格分隔的字段表示: 字段名 ...
6、基于Quartz.Net的定时任务控制,可随时启/停,可视化配置Cron表达式功能 7、基于CodeSmith的代码生成功能,可快速生成带有头/明细结构的页面 8、支持sqlserver、mysql数据库,理论上支持所有数据库 9、集成...
6、基于Quartz.Net的定时任务控制,可随时启/停,可视化配置Cron表达式功能 7、基于CodeSmith的代码生成功能,可快速生成带有头/明细结构的页面 8、支持sqlserver、mysql数据库,理论上支持所有数据库 9、集成...