How to get cron from application.yml.
application.yml:
cron-expression:
every: ${CRON:* * * ? * *}
DTO:
@Configuration
@ConfigurationProperties(prefix = "cron-expression")
class ConfigDTO {
String every;
public String getEvery(){
return every;
}
}
Schedule
public Class Schedule{
@Autowired
private ConfigDTO dto;
@Scheduled(cron = dto.getEvery())
public void test(){
Systems.out.println("date time",newDate());
}
}
Is there any possibility to handle like above