在Grails 2中,我们使用内部库来动态设置Config.groovy文件中的属性值。该库查看了特定于环境的配置管理数据库并填充了这些值。这是在Grails 2中运行的配置示例
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
^
建议?
答案 0 :(得分:0)
事实证明,您无法直接设置属性,但可以声明局部变量,然后使用该值设置属性。
import com.mycompany.otherproject.ConfigurationManagement
def dynamicProperty = ConfigurationManagement.getValue("dynamic.property.name", "default")
family {
dynamic.property = dynamicProprty
static.proprty = "static value"
}