在我的 grials 应用程序中,我有一个正在运行的工作,这就是它的触发防御:
static triggers = {
simple name: 'myJob', startDelay: 1000, repeatInterval: 36000000
}
我想改变它,不应该对值进行硬编码,但它们应该取自 congif/properties 文件。
我试过这个:
配置.groovy:
myJob {
simpleName = 'myJob'
startDelay = '1000'
repeatInterval = '36000000'
}
并在工作触发器中:
static triggers = {
simple name: grailsApplication.config.myJob.name, startDelay: grailsApplication.config.myJob.startDelay, repeatInterval: grailsApplication.config.myJob.repeatInterval
}
但随后我收到一条消息:无法从静态上下文中引用非静态符号“grailsApplication”。
有没有人有更好的想法如何做到这一点?
谢谢。