gpt4 book ai didi

cron - 使用属性文件中的 cron 表达式进行任务调度

转载 作者:行者123 更新时间:2023-12-02 13:59:29 25 4
gpt4 key购买 nike

我写了一个 cron 作业:

@Scheduled(cron="${process.virtual.account.start}")
public void ecomProcessVirAccOrderPaymentsScheduler() {
LOGGER.info("Start --->" + this.getClass().getCanonicalName() + ".ecomProcessVirAccOrderPaymentsScheduler() Method");
schedulerJobHelper.ecomProcessVirAccOrderPaymentsScheduler();
LOGGER.info("End --->" + this.getClass().getCanonicalName() + ".ecomProcessVirAccOrderPaymentsScheduler() Method");
}

我想要从外部属性文件中获取与 @Scheduled 注释一起使用的 cron 属性。目前我正在从应用程序范围内的属性文件中获取它。我能够获取该值,但无法将其与 @Schedule 注释一起使用。

最佳答案

它在 Spring Boot 中工作。

@Scheduled(cron="${cronExpression}")
private void testSchedule() {
System.out.println("Helloooo");
}

application.properties 中,我有一个如下所示的属性:

cronExpression=* * * ? * *

关于cron - 使用属性文件中的 cron 表达式进行任务调度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24306004/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com