I use Spring 4. I run Spring context like:
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
context.scan(BASE_PACKAGE);
context.refresh();
I use injecting of environment variables like:
@Value("#{systemEnvironment['ENV_VAR'] ?: 60}")
private int someDelay;
And it works pretty fine.
The question is how to make this work:
@Scheduled(fixedDelayString = "${ENV_VAR ?: 60000}")
public void runSomeTask(){
System.out.println("hello ");
}
Now spring throws exception:
Initialization of bean failed; nested exception is java.lang.IllegalStateException: Encountered invalid @Scheduled method 'runSomeTask': Invalid fixedDelayString value "${ENV_VAR ?: 60000}" - cannot parse into integer
I suppose I need to create a BeanPostProcessor which is responsible for processing such values, but I have no idea which one exactly.
P.S. It works fine with Spring Boot out of the box.