0

I have this code but I dont want the fixedRate flag to be hardcoded to 20000. Is it possible to put the 20000 in a property file and read that value inside my @Scheduled annotation?

@CacheEvict(allEntries = true, value = "fooResponse")
@Scheduled(fixedRate = 20000)
public void reportCacheEvict() {

    logger.debug("Doing Stuff on a fixed rate Schedule");
}
javaPlease42
  • 4,699
  • 7
  • 36
  • 65
  • No. see [this](https://stackoverflow.com/questions/10636201/java-annotations-values-provided-in-dynamic-manner) – JJF Oct 29 '19 at 18:52
  • 1
    That can be done with the `fixedRateString` attribute. That can take a SpEL or value expression to be resolved at startup. – M. Deinum Oct 29 '19 at 18:53
  • An example to Deinums answere would be: @Scheduled(fixedRateString = "#{schedulerProperties.crawlRefreshInterval}") where schedeulerProperties is a PropertyBean – Chr3is Oct 29 '19 at 19:24

0 Answers0