Bur*_*ith 25
你最好的选择是Config.groovy.任何类都可以访问ConfigurationHolder.getConfig(),使其成为全局变量,甚至可以为变量提供特定于环境的值.
someVar = "foo"
environments {
production {
grails.serverURL = "http://www.changeme.com"
someOtherVar = 1000
}
development {
grails.serverURL = "http://localhost:8080/${appName}"
someOtherVar = 100
}
test {
grails.serverURL = "http://localhost:8080/${appName}"
someOtherVar = 0
}
}
Run Code Online (Sandbox Code Playgroud)