小编Ara*_*289的帖子

如何在不使用 @Scheduled() 注释的情况下在 Spring Boot 中安排 cron 作业

在 spring boot 中,我可以通过不使用@Scheduled方法的注释来安排 spring 作业吗?

我正在春季靴中从事春季工作。我想通过使用 cron 表达式来安排作业,但不使用@Scheduled(cron = " ")该方法的注释。

我知道我可以在这个方法中安排一个工作,如下所示。

@Scheduled (cron = "0 10 10 10 * ?")

public void execute() { 

   / * some job code * /

}
Run Code Online (Sandbox Code Playgroud)

但我希望它是动态的,以便我可以将 cron 表达式作为用户的输入并安排它。

cron spring job-scheduling spring-scheduled spring-boot

5
推荐指数
1
解决办法
5335
查看次数