Inject @Scheduled fixedRate value from Spring Boot application.yml file

In my application.properties (YAML) I put this

console:
    fetchMetrics: 5000

Then in my simple Task class I push the definition :

@Scheduled(fixedRateString ="${console.fetchMetrics}", initialDelay=1000)
public void fetchMetrics() {
    logger.info("What's up ?");
}

Please notice that fixedRate expects a long and you want to inject a placeholder, you will need fixedRateString

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)