在Grails 2中,我們使用內部庫來動態設置Config.groovy文件中的屬性值。該庫查看特定於環境的配置管理數據庫並填充這些值。這是在Grails的2Grails3 application.groovy動態屬性
import com.mycompany.otherproject.ConfigurationManagement
family {
dynamic.property = ConfigurationManagement.getValue("dynamic.property.name", "default")
static.proprty = "static value"
}
基礎上Upgrading from Grails 2.x - Reference Documentation工作的配置的一個例子,我複製此信息application.groovy,但現在我碰到下面的錯誤,我一直未能解決。
Error |
Error occurred running Grails CLI: startup failed:
script14930638938641309394273.groovy: 1: unable to resolve class com.mycompany.otherproject.ConfigurationManagement
@ line 1, column 1.
import com.mycompany.otherproject.ConfigurationManagement
^
建議?
您是否嘗試不導入類,而是調用'com.mycompany.otherproject.ConfigurationManagement'或它的實例中的方法?你確定類是存在於你的類路徑中嗎? –
我正在使用IntelliJ Idea,如果我使用導入,那麼我可以跳轉到方法定義。如果我刪除導入,那麼我不能再這樣做,並且構建會給我一個不同的錯誤:運行Grails CLI時發生錯誤:沒有方法簽名:groovy.util.ConfigObject.getValue()適用於參數類型:(java .lang.String,java.lang.String) – GeoGriffin
也許我沒有運行這個權利。我從我的運行配置中執行「grails clean」,就像我在Grails 2中所做的那樣,但我不認爲這是正確的。我較早前完成了這個任務,並且完成了構建步驟,但是我只是爲「gradle clean」和「gradle build」設置了一個新的運行配置,現在我得到了與某些單元測試有關的不同錯誤以及我需要的其他重構。 – GeoGriffin