spring cron expression must consist of 6 fields 。
@Scheduled(cron = "${corn.newChatOrderCheck}")
使用这个注解来定义cron表达式。需要在配置文件里面配置,达到动态读取的效果。
1 在类最前面加配置文件的读取路径。
@PropertySource("classpath:application.properties")
2 在类里面添加以下代码。其实是一个Bean (作用还要继续研究)
@Bean
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
return new PropertySourcesPlaceholderConfigurer();
}
3 在配置文件里面添加
corn.newChatOrderCheck
网友评论