星空网 > 软件开发 > Java

spring mvc 整合Quartz

Quartz是一个完全由java编写的开源作业调度框架。不要让作业调度这个术语吓着你。尽管Quartz框架整合了许多额外功能, 但就其简易形式看,你会发现它易用得简直让人受不了!Quartz整合在spring mvc的步骤:

1)准备spring.jar

2)在WebRoot——>WEB-INF目录下创建spring-listener.

3)在该

使用CronTrigger:

<?class="com.quartz.CommonQuartz"     </bean>    <bean id="quartzTask" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">    <property name="targetObject">     <ref bean="quartzJob"></ref>    </property>    <property name="targetMethod">     <value>TaskFunction</value>    </property>  </bean>    <bean id="startQuartzTime" class="org.springframework.scheduling.quartz.CronTriggerBean">     <property name="jobDetail">     <ref bean="quartzTask"></ref>     </property>     <property name="cronExpression">     <value>*/1 * * * * ? </value>     </property>  </bean>  <bean id="startQuartz" lazy-init="false" autowire="no"  class="org.springframework.scheduling.quartz.SchedulerFactoryBean">   <property name="triggers">     <list>         <ref bean="startQuartzTime"></ref>     </list>   </property>  </bean></beans>

其中cronExpression表达式对特殊字符的大小写不敏感,对代表星期的缩写英文大小写也不敏。

表示式

说明

"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点之间每分钟运行一次,开始于14:00,结束于14:59。

"0 0/5 14 * * ?"

每天14点到15点每5分钟运行一次,开始于14:00,结束于14:55。

"0 0/5 14,18 * * ?"

每天14点到15点每5分钟运行一次,此外每天18点到19点每5钟也运行一次。

"0 0-5 14 * * ?"

每天14:00点到14:05,每分钟运行一次。

"0 10,44 14 ? 3 WED"

3月每周三的14:10分到14: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 2007-2009"

在2007,2008,2009年每个月的最后一个星期五的10:15分运行。

"0 15 10 ? * 6#3"

每月第三个星期五的10:15分运行。

使用SimpleTrigger:

<bean id="simpleTriggerTime" class="org.springframework.scheduling.quartz.SimpleTriggerBean">     <property name="jobDetail">      <ref bean="quartzTask"></ref> 
</property>
<property name="startDelay" value="0" />
<property name="repeatInterval">
<value>3600000</value>
</property>
</bean>

4)在com.quartz.CommonQuartz类下添加TaskFunction方法,该方法即作业调度方法。

 




原标题:spring mvc 整合Quartz

关键词:Spring

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

TikTok Shop印尼风波:电商业态与政商关系的交织:https://www.goluckyvip.com/news/21012.html
Shopee访问量再度登顶东南亚!:https://www.goluckyvip.com/news/21013.html
佣金再涨!东南亚卖家利润又被压缩:https://www.goluckyvip.com/news/21014.html
Shein重仓拉美,加速本土化进程:https://www.goluckyvip.com/news/21015.html
多发货跨境物流|跨境电商新势力:TEMU:https://www.goluckyvip.com/news/21016.html
延误丨随着干旱加剧,巴拿马运河管理局宣布进一步削减预定舱位,运输量将减少 43%:https://www.goluckyvip.com/news/21017.html
探讨内地人开设香港账户的可行性 :https://www.kjdsnews.com/a/1836442.html
在古巴做游轮 古巴旅游项目:https://www.vstour.cn/a/363194.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流