春の @Scheduled メソッドでcronの詳細を定義しようとしていました
@Service
@PropertySource("classpath:application.properties")
public class CacheRefreshService {
@Scheduled(cron = "${api.refresh.cron}")
public void refreshJob() throws Exception {
LOGGER.info("Started Refresh");
//do something
}
}
そして、私のapplication.propertiesで
#Refresh
api.refresh.cron =0 29 11 * * ?
@Scheduled とともに cron の詳細を定義すると、問題なく実行されます。しかし、これを行うと、プロパティ ファイルから値を読み取ることができず、以下のエラーがスローされます。
Caused by: java.lang.IllegalStateException: Encountered invalid @Scheduled method 'refreshJob': Cron expression must consist of 6 fields (found 1 in "${api.refresh.cron}")
何か提案はありますか?