Annotation Interface Scheduled
cron(), fixedDelay(), or fixedRate() 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 a ScheduledAnnotationBeanPostProcessor. This can be
done manually or, more conveniently, through the <task:annotation-driven/>
XML element or @EnableScheduling annotation.
This annotation can be used as a repeatable annotation.
This annotation may be used as a meta-annotation to create custom composed annotations with attribute overrides.
- 从以下版本开始:
- 4.0
- 作者:
- Mark Fisher, Juergen Hoeller, Dave Syer, Chris Beams, Victor Brown, Sam Brannen
- 另请参阅:
-
可选元素概要
可选元素修饰符和类型可选元素说明A cron-like expression, extending the usual UN*X definition to include triggers on the second, minute, hour, day of month, month, and day of week.longExecute the annotated method with a fixed period between the end of the last invocation and the start of the next.Execute the annotated method with a fixed period between the end of the last invocation and the start of the next.longExecute the annotated method with a fixed period between invocations.Execute the annotated method with a fixed period between invocations.longNumber of units of time to delay before the first execution of afixedRate()orfixedDelay()task.Number of units of time to delay before the first execution of afixedRate()orfixedDelay()task.TheTimeUnitto use forfixedDelay(),fixedDelayString(),fixedRate(),fixedRateString(),initialDelay(), andinitialDelayString().A time zone for which the cron expression will be resolved. -
字段概要
字段修饰符和类型字段说明static final StringA special cron expression value that indicates a disabled trigger: "-".
-
字段详细资料
-
CRON_DISABLED
A special cron expression value that indicates a disabled trigger: "-".This is primarily meant for use with
${...}placeholders, allowing for external disabling of corresponding scheduled methods.
-
-
元素详细资料
-
cron
String cronA cron-like expression, extending the usual UN*X definition to include triggers on the second, minute, hour, day of month, month, and day of week.For example,
"0 * * * * MON-FRI"means once per minute on weekdays (at the top of the minute - the 0th second).The fields read from left to right are interpreted as follows.
- second
- minute
- hour
- day of month
- month
- day of week
The special value
"-"indicates a disabled cron trigger, primarily meant for externally specified values resolved by a${...}placeholder.- 返回:
- an expression that can be parsed to a cron schedule
- 另请参阅:
- 默认值:
- ""
-
zone
String zoneA 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 - 另请参阅:
- 默认值:
- ""
-
fixedDelay
long fixedDelayExecute the annotated method with a fixed period between the end of the last invocation and the start of the next.The time unit is milliseconds by default but can be overridden via
timeUnit().- 返回:
- the delay
- 默认值:
- -1L
-
fixedDelayString
String fixedDelayStringExecute the annotated method with a fixed period between the end of the last invocation and the start of the next.The time unit is milliseconds by default but can be overridden via
timeUnit().- 返回:
- the delay as a String value — for example, a placeholder
or a
java.time.Durationcompliant value
- 默认值:
- ""
-
fixedRate
long fixedRateExecute the annotated method with a fixed period between invocations.The time unit is milliseconds by default but can be overridden via
timeUnit().- 返回:
- the period
- 默认值:
- -1L
-
fixedRateString
String fixedRateStringExecute the annotated method with a fixed period between invocations.The time unit is milliseconds by default but can be overridden via
timeUnit().- 返回:
- the period as a String value — for example, a placeholder
or a
java.time.Durationcompliant value
- 默认值:
- ""
-
initialDelay
long initialDelayNumber of units of time to delay before the first execution of afixedRate()orfixedDelay()task.The time unit is milliseconds by default but can be overridden via
timeUnit().- 返回:
- the initial
- 默认值:
- -1L
-
initialDelayString
String initialDelayStringNumber of units of time to delay before the first execution of afixedRate()orfixedDelay()task.The time unit is milliseconds by default but can be overridden via
timeUnit().- 返回:
- the initial delay as a String value — for example, a placeholder
or a
java.time.Durationcompliant value
- 默认值:
- ""
-
timeUnit
TimeUnit timeUnitTheTimeUnitto use forfixedDelay(),fixedDelayString(),fixedRate(),fixedRateString(),initialDelay(), andinitialDelayString().Defaults to
TimeUnit.MILLISECONDS.This attribute is ignored for cron expressions and for
Durationvalues supplied viafixedDelayString(),fixedRateString(), orinitialDelayString().- 返回:
- the
TimeUnitto use
- 默认值:
- MILLISECONDS
-