@Target({ElementType.METHOD, ElementType.ANNOTATION_TYPE}) @Retention(RetentionPolicy.RUNTIME) @Documented @Repeatable(Schedules.class) public @interface Scheduled { /** * A special cron expression value that indicates a disabled trigger: {@value}. * 一个特殊的cron表达式值,指示禁用的触发器:{@value}。 * <p>This is primarily meant for use with <code>${...}</code> placeholders, * allowing for external disabling of corresponding scheduled methods. * @since 5.1 * @see ScheduledTaskRegistrar#CRON_DISABLED */ String CRON_DISABLED = ScheduledTaskRegistrar.CRON_DISABLED; /** * 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. * 类似cron的表达式,将通常的UN*X定义扩展为包括触发器在秒、分钟、小时、天、月份和星期几。 * * <p>For example, {@code "0 * * * * MON-FRI"} means once per minute on weekdays * (at the top of the minute - the 0th second). * <p>The fields read from left to right are interpreted as follows. * 从左到右读取的字段解释如下。 * <ul> * <li>second</li> * <li>minute</li> * <li>hour</li> * <li>day of month</li> * <li>month</li> * <li>day of week</li> * </ul> * <p>The special value {@link #CRON_DISABLED "-"} indicates a disabled cron * trigger, primarily meant for externally specified values resolved by a * <code>${...}</code> placeholder. * @return an expression that can be parsed to a cron schedule * @see org.springframework.scheduling.support.CronExpression#parse(String) */ String cron() default ""; /** * A time zone for which the cron expression will be resolved. * 将解析cron表达式的时区。 * By default, this attribute is the empty String (i.e. the server's local time zone will be used). * 默认情况下,此属性为空字符串(即将使用服务器的本地时区)。 * @return a zone id accepted by {@link java.util.TimeZone#getTimeZone(String)}, * or an empty String to indicate the server's default time zone * @since 4.0 * @see org.springframework.scheduling.support.CronTrigger#CronTrigger(String, java.util.TimeZone) * @see java.util.TimeZone */ String zone() default ""; /** * Execute the annotated method with a fixed period in milliseconds between the * end of the last invocation and the start of the next. * 在上一次调用结束和下一次调用开始之间以毫秒为单位的固定周期内执行带注释的方法。 * * @return the delay in milliseconds */ long fixedDelay() default -1; /** * Execute the annotated method with a fixed period in milliseconds between the * end of the last invocation and the start of the next. * 在上一次调用结束和下一次调用开始之间以毫秒为单位的固定周期内执行带注释的方法。 * * @return the delay in milliseconds as a String value, e.g. a placeholder * or a {@link java.time.Duration#parse java.time.Duration} compliant value * @since 3.2.2 */ String fixedDelayString() default ""; /** * Execute the annotated method with a fixed period in milliseconds between * invocations. * 在两次调用之间以毫秒为单位执行带注释的方法。 * * @return the period in milliseconds */ long fixedRate() default -1; /** * Execute the annotated method with a fixed period in milliseconds between * invocations. * 在两次调用之间以毫秒为单位执行带注释的方法。 * * @return the period in milliseconds as a String value, e.g. a placeholder * or a {@link java.time.Duration#parse java.time.Duration} compliant value * @since 3.2.2 */ String fixedRateString() default ""; /** * Number of milliseconds to delay before the first execution of a * {@link #fixedRate} or {@link #fixedDelay} task. * 首次执行{@link#fixedRate}或{@link#fixedDelay}任务之前要延迟的毫秒数。 * * @return the initial delay in milliseconds * @since 3.2 */ long initialDelay() default -1; /** * Number of milliseconds to delay before the first execution of a * {@link #fixedRate} or {@link #fixedDelay} task. * 首次执行{@link#fixedRate}或{@link#fixedDelay}任务之前要延迟的毫秒数。 * * @return the initial delay in milliseconds as a String value, e.g. a placeholder * or a {@link java.time.Duration#parse java.time.Duration} compliant value * @since 3.2.2 */ String initialDelayString() default ""; }