简体   繁体   English

@Scheduled注解Spring

[英]@Scheduled annotation Spring

I am using Spring 3 annotation @Scheduled to create scheduled jobs on server. 我正在使用Spring 3注解@Scheduled在服务器上创建计划的作业。 But i am confused about the parameters( cron , fixedDelay , fixedRate ) of @Scheduled annotation. 但是我对@Scheduled批注的参数( cronfixedDelayfixedRate )感到困惑。 Please explain the difference between these parameter and the situations in which I can use these parameters. 请说明这些参数与我可以使用这些参数的情况之间的区别

I believe the difference among different options are made clear here . 我相信在这里可以清楚看出不同选择之间的区别。 It depends on how you need to execute the task: 这取决于您需要如何执行任务:

  1. fixedRate makes Spring run the task on periodic intervals even if the last invocation may be still running. fixedRate使Spring 定期运行任务,即使最后一次调用可能仍在运行。
  2. fixedDelay specifically controls the next execution time when the last execution finishes. fixedDelay特别控制最后一次执行完成时的下一个执行时间。
  3. cron is a feature originating from Unix cron utility and has various options based on your requirements. cron是源自Unix cron实用程序的功能,根据您的要求有多种选择。

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. cron:类似于cron的表达式,扩展了通常的UN * X定义,以包括秒,分,时,月,日和星期几的触发器。

fixedDelay : Execute the annotated method with a fixed period between the end of the last invocation and the start of the next. fixedDelay:在上一次调用的结束与下一次调用的开始之间以固定的时间间隔执行带注释的方法。

fixedRate : Execute the annotated method with a fixed period between invocations. fixedRate:在两次调用之间以固定的时间间隔执行带注释的方法。

http://static.springsource.org/spring/docs/3.0.x/javadoc-api/org/springframework/scheduling/annotation/Scheduled.html http://static.springsource.org/spring/docs/3.0.x/javadoc-api/org/springframework/scheduling/annotation/Scheduled.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM