Grails 構成ファイルには、次のような 3 つの環境ブロックがあります。
environments {
production {
grails.serverURL = "https://www.mysite.com"
}
development {
grails.serverURL = "http://localhost:8080/${appName}"
}
test {
grails.serverURL = "http://localhost:8080/${appName}"
}
}
... // more code
environments {
production {
authnet.apiId = "123456"
authnet.testAccount = "false"
}
development {
authnet.apiId = "654321"
authnet.testAccount = "true"
}
test {
authnet.apiId = "654321"
authnet.testAccount = "true"
}
}
... // more code
environments {
production {
email.sales = 'sales@mysite.com'
}
development {
email.sales = 'test@mysite.com'
}
test {
email.sales = 'test@mysite.com'
}
}
コントローラーのどこかに:
println grailsApplication.config.grails.serverURL
println grailsApplication.config.authnet.apiId
println grailsApplication.config.email.sales
次のように出力されます。
http://localhost:8080/myapp
[:]
test@mysite.com
そのため、何らかの理由でアプリが一部の環境ブロックからデータを取得できません。環境ブロックの外側のものは問題ありません。いくつかの異なるアプリ、異なる構成などでこの問題に気付きました.grailsApplicationとConfigurationHolderの両方で取得しようとしました。それはGrailsのバグですか、それとも何か間違っていますか? Grails 1.3.6 を実行しています