Question
How do I define Spring Expression Language (SpEL) in groovy spring boot project? (Per spring scheduler crontab @scheduled annotation)
Spring Boot Groovy and Spring EL Scheduler
Per documentation from the web, I'm dinking around with spring scheduler in my groovy spring boot application (2.2.x)
Per this post: Task scheduling using cron expression from properties file
Tried this
I've tried defining my cron expression both as follows:
@Scheduled(cron = "${appConfig.defaultCron}")
and
@Scheduled(cron = "#{appConfig.defaultCron}")
but get this error:
Attribute 'cron' should have type 'java.lang.String'; but found type 'java.lang.Object' in @org.springframework.scheduling.annotation.Scheduled
Analysis
It seems that the spring 'cron cruncher' sees the "${xxx}" as a Gstring and not as a string
Question
How do I get SpringEL work in cron definition in groovy spring boot project?
References https://www.baeldung.com/spring-scheduled-tasks
https://www.baeldung.com/spring-expression-language
Inject @Scheduled fixedRate value from Spring Boot application.yml file
'${...}'
or"\${...}"
? – cfrick