Grails配置配置器
我想把配置文件分成几个小部分。在Grails配置配置器,grails,groovy,Grails,Groovy,我想把配置文件分成几个小部分。在Config.groovy中,我定义了grails.Config.locations数组来指向这些文件: grails.config.locations = [ "classpath:config.properties", "classpath:some-config.groovy", ] 然后我通过访问:grailsApplication.config 第一个配置文件是Java属性文件,可正确加载: config.properties 第二个是
Config.groovy
中,我定义了grails.Config.locations
数组来指向这些文件:
grails.config.locations = [
"classpath:config.properties",
"classpath:some-config.groovy",
]
然后我通过访问:grailsApplication.config
第一个配置文件是Java属性文件,可正确加载:
config.properties
第二个是.groovy
文件,参考文档()应从自动解析的ConfigSlurper
文件格式加载该文件:
some-config.groovy:
但是grailsApplication.config.app
不存在(调试中没有字段,println
返回空映射[:]
)
有人能举一个加载groovy文件的例子吗
文件放置在:
grails-app\conf\
,例如grails-app\conf\config.properties
看起来您已经正确配置了这两个文件grailsApplication.config.app
可能是空的,因为它不是叶节点,您是否尝试过grailsApplication.config.app.testvar.foo
?Howdy@Dónal。是的,我试过grailsApplication.config.app.testvar.foo
,但它也是空的map[:]
。尾随逗号不重要()。@Athlan感谢链接,我不知道尾随逗号是官方允许的。我不确定这为什么不起作用,您能否通过将.groovy
配置文件转换为.properties
文件来解决这个问题?
grails.serverURL=http://localhost:8080/selly
..
app {
testvar {
foo = true
}
}