欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

spring-task的属性理解

程序员文章站 2024-02-22 23:40:52
...

案例:

	<task:scheduled-tasks>
		<!-- <task:scheduled ref="timeJob" method="getWeChatOpenId" cron="0 0/1 * * * ?" /> -->
		<!-- <task:scheduled ref="timeJob" method="getWeChatOpenId" cron="0 50 23 1/1 * ? " /> -->
		<task:scheduled ref="xytimeJob" method="executeXYWithout" cron="0 0/1 * * * ?" />
		<!-- <task:scheduled ref="buJianTimeOut" method="rejectBuJianTimeOut" cron="0 0 0 * * ?" /> -->
		<task:scheduled ref="buJianTimeOut" method="rejectBuJianTimeOut" cron="0 0/1 * * * ?" />
		<task:scheduled ref="timeJob" method="withholdSign" cron="0 0/1 * * * ? " />
	</task:scheduled-tasks>


名称解释:

ref注入类,注入定时任务的bean

method是工作类中要执行的方法

fixed-delay是上一个调用完成后再次调用的延时

fixed-rate是上一个调用开始后再次调用的延时(并行执行,不用等待上一次调用完成)

cron是表达式,表示在什么时候进行任务调度(使用cron表达式的时候task是串行的)。