Pass a YAML-based property value to @Scheduled annotation in Spring Boot -


this question possibly duplicate of older question.

i'm working on spring boot 1.4 application , have method of bean annotated @scheduled. need pass cron value annotation and, since i'm using yaml based configuration, cron value stored in yaml file (application.yaml).

i can't find way pass property value app.cron annotation.

for instance, doesn't work

@scheduled(cron = ${app.cron}) 

i have tried use el expression, no luck.

what proper way pass yaml based property value spring annotation?

try putting in javaconfig first , should work el:

@configuration @configurationproperties(prefix = "app") public class cronconfig() {     private string cron;      @bean     public string cron() {         return this.cron;     }       public void setcron(string cron) {        this.cron = cron;     } } 

and use @scheduled(cron = "#{@cron}")

i didn't tried scheduled taks had similar problem injecting annotation.


Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -