I'm using spring framework v4.1.7 and have issues scheduling a cron task where i want to define the cron parameter in a property file.
My java code:
@Scheduled(cron = "${invoice.export.cron}")
private void scheduledExport() {
// ... the code to execute ...
}
and in my properties file i have invoice.export.cron: 0 0 7 * * MON-FRI?
to enable scheduling i have @EnableScheduling
on my main configuration class.
I tried to debug into this issue and found that the cron expression should be resolved from the property placeholder here. following the calls into resolveStringValue
brings me to this location into AbstractBeanFactory
. And as far as i can see, here is the problem. the this.embeddedValueResolvers
list is empty... therefore it does not resolve the property i passed to @Scheduled(cron)
.
anyone has an idea if i'm doing something wrong or miss something here?
Thanks in advance! :)