Closed
Description
Sean Stephenson opened SPR-14114 and commented
I have a @Scheduled
method that should execute every N seconds, where N is an interval specified in a config file. Here is how my declaration looks.
@Scheduled
(fixedDelayString = "#{${myapp.intervalInSeconds} * 1000}")
public void run() {
// ...
}
Unfortunately, while specifying a property replace expression like "${myapp.intervalInSeconds}" works correctly, using a SpEL expression to convert this to milliseconds does not work. I get the following error message on attempting to start Spring.
Caused by: java.lang.IllegalStateException: Encountered invalid @Scheduled
method 'run': Invalid fixedDelayString value "#{10 * 1000}" - cannot parse into integer
Affects: 4.1.7
Issue Links:
- Support SpEL next to placeholders in annotation attributes (e.g. @Scheduled) [SPR-13625] #18203 Support SpEL next to placeholders in annotation attributes (e.g.
@Scheduled
) ("duplicates")