在我grials應用我有一個運行工作,這其觸發defenition找到工作觸發值:Grails的 - 從一個配置文件
static triggers = {
simple name: 'myJob', startDelay: 1000, repeatInterval: 36000000
}
我想改變它的值shouln't是硬編碼,但它們應該從congif/properties文件中獲取。
我嘗試這樣做:
Config.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 '從靜態的上下文。
有沒有人有更好的主意怎麼做?
謝謝。
@Dvora這應該被標記爲正確答案。 –