我在kotlin中使用spring 5,我有以下代码
@Scheduled(cron = "${job.notification.expiring.x}")
fun notify() {
}
在application.yml中
job:
notification:
expiring.x: 0 0 12 1/1 * ?
在@schedulled
的行中,cron
参数注释Intellij说
An annotation parameter must be a compile-time constant.
如何解决这个问题,在Java中,属性是在运行时加载的。
发布于 2018-03-08 02:20:42
您需要转义Kotlin中的$字符,因为这用于字符串模板:
@Scheduled(cron = "\${job.notification.expiring.x}")
请参阅本页底部关于字符串模板的部分:
https://stackoverflow.com/questions/49170602
复制