How to parameterize @Scheduled(fixedDelay) with Spring 3.0 expression language?

前端 未结 5 1412
谎友^
谎友^ 2020-11-28 21:21

When using the Spring 3.0 capability to annotate a scheduled task, I would like to set the fixedDelay as parameter from my configuration file, instead of hard-w

5条回答
  •  一向
    一向 (楼主)
    2020-11-28 21:46

    Spring v3.2.2 has added String parameters to the original 3 long parameters to handle this. fixedDelayString, fixedRateString and initialDelayString are now available too.

    @Scheduled(fixedDelayString = "${my.fixed.delay.prop}")
    public void readLog() {
            ...
    }
    

提交回复
热议问题