一个 cronExpression 表达式有至少6个(也可能是7个)由空格分隔的时间元素。从左至右,这些元素的定义如下:
1.秒(0–59)
2.分钟(0–59)
3.小时(0–23)
4.月份中的日期(1–31)
5.月份(1–12或JAN–DEC)
6.星期中的日期(1–7或SUN–SAT)
7.年份(1970–2099)
0 0 10,14,16 * * ?
每天上午10点,下午2点和下午4点
0 0,15,30,45 * 1-10 * ?
每月前10天每隔15分钟
30 0 0 1 1 ? 2012
在2012年1月1日午夜过30秒时
0 0 8-5 ? * MON-FRI
每个工作日的工作时间
各个时间可用值如下:
序号 说明
是否必填 允许填写的值 允许的通配符
1 秒 是 0-59 , - * /
2 分 是 0-59
, - * /
3 小时 是 0-23 , - * /
4 日 是 1-31 , - * ? / L W
5 月 是 1-12 or JAN-DEC , - * /
6 周 是 1-7 or SUN-SAT , - * ? / L #
7 年 否 empty 或 1970-2099 , - * /
举个例子:
<bean id="reportJob"
class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject" ref="report" />
<property name="targetMethod" value="execute" />
<property name="concurrent" value="false" />
</bean>
定义一个发送短信自动做报表的
<bean id="reportTrigger"
class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail" ref="reportJob" />
<property name="cronExpression" value="0 1/10 * * * ?" />
</bean>
每隔10分钟做一次
<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="reportTrigger" />
</list>
</property>
</bean>
设置定时的启动列表
相关推荐
java开发之spring定时任务时间格式cronexpression设置.docx
3、自定义(自定义功能,用户可以在前台随意定制执行计划,只要符合spring schedule cronExpression语法) 亮点: i:日期选择功能使用JEasyUI的datetime,并在选择框上加了限制,不能选择早于当前的日期 ii:时间...
spring定时任务 xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xsi:schemaLocation=...
3、自定义(自定义功能,用户可以在前台随意定制执行计划,只要符合spring schedule cronExpression语法) 使用说明: 一: /* line 96 */ var action = "edit";//edit,add,view action用来指定用户动作,新增、...
Spring Quartz如何动态配置时间
(1)定时 秒分时日月周年 <property name="cronExpression"> <value>0 0 12 * * ? (2)注意事项 在SSH整合应用时,需要删除重复的“common-collections-1.1.2.jar”文件, 保留“common-collections-3.2.jar”文件
<!-- 每天的8点到21点每隔1分钟触发,具体说明见附录 --> <property name="cronExpression"> <value>0 * 08-21 * * ? </property>
7 import org.quartz.CronExpression; 8 import org.springframework.util.Assert; 9 10 import java.text.ParseException; 11 import java.util.Date; 12 import java.util.List; 13 14 /** 15 * ******...
<property name="cronExpression"> <value>0 0 2,17 * * ? <!-- 最终启动的配置 --> class="org.springframework.scheduling.quartz.SchedulerFactoryBean"> </bean>
Spring+quartz 一个简单的 定时任务的例子,希望能对大家的学习有帮助。 最后,附:cronExpression配置说明 字段 允许值 允许的特殊字符 秒 0-59 , - * / 分 0-59 , - * / 小时 0-23 , - * / 日期 1-31 , - *...
-- 定时任务 方式2(集群方式)--> class="frameworkx.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"> <property name="shouldRecover" value="false"></property> ...