I am using spring 5 with kotlin and I have the following code
@Scheduled(cron = "${job.notification.expiring.x}")
fun notify() {
}
and in application.yml
job:
notification:
expiring.x: 0 0 12 1/1 * ?
On the line with the @schedulled
, at cron
parameter annotation Intellij says
An annotation parameter must be a compile-time constant.
How can I fix this, in Java the properties were loaded at run time.
You need to escape the $ character in Kotlin since this is used for String templates:
@Scheduled(cron = "\${job.notification.expiring.x}")
See the section on String templates at the bottom of this page:
https://kotlinlang.org/docs/reference/basic-types.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With