无法避免在启动时触发作业

Unable to avoid job triggering at Start up

我正在使用批处理,我希望它 运行 在特定的 cron 计划时间。但是,作业在启动时被触发,并在预定时间再次触发。我试图避免前者但是没有这样做。这是一个重现相同问题的示例存储库:https://github.com/ppanigrahi02/BatchJobWithScheduler. i am using the spring guide example https://github.com/spring-guides/gs-batch-processing 并在其上添加了一个调度程序。我将非常感谢任何线索。

使用的 @Scheduled 注解 here 将在启动时立即启动作业,并且每 600000 毫秒启动一次作业。如果你想在第一次执行之前指定一个初始延迟等待,你可以使用注释的 initialDelay 属性,比如:

@Scheduled(initialDelay = 600000, fixedRate = 600000)

另一种选择是使用 cron 属性并提供一个 cron 表达式。有关此注释的更多详细信息,您可以在此处查看参考文档:https://docs.spring.io/spring/docs/5.0.3.RELEASE/spring-framework-reference/integration.html#scheduling-annotation-support-scheduled