java - Spring Boot cron 表达式问题 - 禁用启动时运行

标签 java spring spring-boot cron

我有一个带有预定作业的 Spring boot 应用程序。我想要的只是每天中午 12 点启动我的作业,但我不希望该作业在 Spring boot 应用程序启动时启动。

我的 cron 表达式是 0 0 12 1/1 * ? *

有人可以帮助我吗?

最佳答案

@Scheduled(cron = "0 0 12 * * *")
//@Scheduled(fixedRate = 4000)
public void processMyTask() {
   ...
}

这个 cron 表达式“0 0 12 * * *” 应该可以工作。我在进行开发并希望出于测试目的执行时使用固定速率值,因此请确保您的方法已正确注释。

关于java - Spring Boot cron 表达式问题 - 禁用启动时运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57257075/

相关文章:

java - 带有 ResponseEntity 的 HttpStatus 和 pdf

java - 获取 InvalidMappingException : Could not parse mapping document from resource

java - 从 Java 代码填充 Spring "property"

java - 为 Spring Batch 应用程序初始化 H2 数据库

java - 是否可以使用 Apache POI XSSF 设置 Activity 范围?

java - 发送 GET 请求时无法将类型 'java.lang.String' 的值转换为所需类型 'java.util.Date'

Spring 启动/Tomcat, "Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean"

java - 为什么 Controller 代码没有在 spring boot 应用程序中执行

java - 带有 AsyncRestTemplate Netty 客户端的 Spring Boot 失败

java - 封装到底是什么?