我正在使用Grails 2.3.8和外部配置运行测试,但价值似乎没有通过。我在旧版本中试过这个,但没有看到同样的错误。有什么东西改变了,还是我错过了一些我胖的东西?我使用绝对路径,文件肯定存在,因为Grails看到了密钥。
Config.groovy中
reliable.string = "This string is working"
grails.config.locations = ["file:/home/howes/Project/project/test-config.groovy"]
/home/howes/Project/project/test-config.groovy
test.externalstring = "this is a test"
为了测试它,我制作了一个控制器,只是调用grailsApplication来取出值。第一次加载页面时,我得到一张空白地图,当我刷新时,我看到了键但没有值。为了确保我正确地提取所有内容,我输出了test-config.groovy项目和一个来自基本Config.groovy的项目。
TestContoller.groovy
class TestController {
def grailsApplication
def index() {
println grailsApplication.config.test
println grailsApplication.config.reliable
return [ext:grailsApplication.config.test.externalstring, ext2:grailsApplication.config.reliable.string]
}
}
控制台输出(首次加载)
[:]
[string:This string is working]
控制台输出(页面刷新)
[externalstring:[:]]
[string:This string is working]
我在这里缺少什么?