定时任务中@Scheduled cron 如何更改从配置信息中获取

1 添加

import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
@Bean
public static PropertySourcesPlaceholderConfigurer propertyConfigInDev() {
return new PropertySourcesPlaceholderConfigurer();//  //使spring能够识别 ${cron} 
}

@Scheduled(cron = "${cron}")//每隔5分钟执行一次
这样就可以了

posted on 2019-07-04 16:45  浅笑灬  阅读(4622)  评论(0编辑  收藏  举报

导航