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

前端 未结 3 1616
星月不相逢
星月不相逢 2020-12-29 02:08

I know I can inject the value from properties file with the following syntax:

@Scheduled(fixedRate=${myRate})
public void getSchedule(){
    System.out.print         


        
3条回答
  •  无人及你
    2020-12-29 03:03

    I find it easy once done for my project.
    Change fixedRate to fixedRateString and put the property key in double quotes like this:

    @Scheduled(fixedRateString="${myRate}")
    public void getSchedule() {
        System.out.println("Scheduled job");
    }
    

提交回复
热议问题