注释类型 Scheduled
@Target({METHOD,ANNOTATION_TYPE}) @Retention(RUNTIME) @Documented @Repeatable(Schedules.class) public @interface Scheduled
An annotation that marks a method to be scheduled. Exactly one of thecron()
,fixedDelay()
, orfixedRate()
attributes must be specified.The annotated method must expect no arguments. It will typically have a
void
return type; if not, the returned value will be ignored when called through the scheduler.Processing of
@Scheduled
annotations is performed by registering aScheduledAnnotationBeanPostProcessor
. This can be done manually or, more conveniently, through the<task:annotation-driven/>
element or @EnableScheduling
annotation.This annotation may be used as a meta-annotation to create custom composed annotations with attribute overrides.
- 从以下版本开始:
- 3.0
- 作者:
- Mark Fisher, Juergen Hoeller, Dave Syer, Chris Beams
- 另请参阅:
EnableScheduling
,ScheduledAnnotationBeanPostProcessor
,Schedules
可选元素概要
可选元素 修饰符和类型 可选元素 说明 String
cron
A cron-like expression, extending the usual UN*X definition to include triggers on the second as well as minute, hour, day of month, month and day of week.long
fixedDelay
Execute the annotated method with a fixed period in milliseconds between the end of the last invocation and the start of the next.String
fixedDelayString
Execute the annotated method with a fixed period in milliseconds between the end of the last invocation and the start of the next.long
fixedRate
Execute the annotated method with a fixed period in milliseconds between invocations.String
fixedRateString
Execute the annotated method with a fixed period in milliseconds between invocations.long
initialDelay
Number of milliseconds to delay before the first execution of afixedRate()
orfixedDelay()
task.String
initialDelayString
Number of milliseconds to delay before the first execution of afixedRate()
orfixedDelay()
task.String
zone
A time zone for which the cron expression will be resolved.
元素详细资料
cron
String cron
A cron-like expression, extending the usual UN*X definition to include triggers on the second as well as minute, hour, day of month, month and day of week.E.g.
"0 * * * * MON-FRI"
means once per minute on weekdays (at the top of the minute - the 0th second).- 返回:
- an expression that can be parsed to a cron schedule
- 另请参阅:
CronSequenceGenerator
- 默认值:
- ""
zone
String zone
A time zone for which the cron expression will be resolved. By default, this attribute is the empty String (i.e. the server's local time zone will be used).- 返回:
- a zone id accepted by
TimeZone.getTimeZone(String)
, or an empty String to indicate the server's default time zone - 从以下版本开始:
- 4.0
- 另请参阅:
CronTrigger(String, java.util.TimeZone)
,TimeZone
- 默认值:
- ""
fixedDelay
long fixedDelay
Execute the annotated method with a fixed period in milliseconds between the end of the last invocation and the start of the next.- 返回:
- the delay in milliseconds
- 默认值:
- -1L
fixedDelayString
String fixedDelayString
Execute the annotated method with a fixed period in milliseconds between the end of the last invocation and the start of the next.- 返回:
- the delay in milliseconds as a String value, e.g. a placeholder
- 从以下版本开始:
- 3.2.2
- 默认值:
- ""
fixedRate
long fixedRate
Execute the annotated method with a fixed period in milliseconds between invocations.- 返回:
- the period in milliseconds
- 默认值:
- -1L
fixedRateString
String fixedRateString
Execute the annotated method with a fixed period in milliseconds between invocations.- 返回:
- the period in milliseconds as a String value, e.g. a placeholder
- 从以下版本开始:
- 3.2.2
- 默认值:
- ""
initialDelay
long initialDelay
Number of milliseconds to delay before the first execution of afixedRate()
orfixedDelay()
task.- 返回:
- the initial delay in milliseconds
- 从以下版本开始:
- 3.2
- 默认值:
- -1L
initialDelayString
String initialDelayString
Number of milliseconds to delay before the first execution of afixedRate()
orfixedDelay()
task.- 返回:
- the initial delay in milliseconds as a String value, e.g. a placeholder
- 从以下版本开始:
- 3.2.2
- 默认值:
- ""