[英]spring with kotlin scheduled annotation getting params from properties file
我使用带有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中,属性是在运行时加载的。
您需要转义Kotlin中的$字符,因为它用于字符串模板:
@Scheduled(cron = "\${job.notification.expiring.x}")
请参阅本页底部的字符串模板部分:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.