转载自:https://www.cnblogs.com/yishang/p/11133371.html
1 类中添加
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
@Bean
public static PropertySourcesPlaceholderConfigurer propertyConfigInDev() {
return new PropertySourcesPlaceholderConfigurer();// //使spring能够识别 ${cron}
}
@Scheduled(cron = "${cron}")
这样就可以了
2 yml中添加cron即可
cron: 0 51 13 * * ?