grails.util.Environment, defines a number of preconfigured environments
- DEVELOPMENT
- PRODUCTION
- TEST
- CUSTOM
When running a Grails command, the environment to use can be specified using a -Denv
flag, e.g. grails run-app -Denv=test
. You can also specify a block of code that is specific to a certain environment using closures such as:
environments {
production {
grails.serverURL = "http://www.changeme.com"
}
development {
grails.serverURL = "http://localhost:8080/${appName}"
}
test {
grails.serverURL = "http://localhost:8080/${appName}"
}
}
These environment-specific closures can be used in Bootstrap.groovy
and Config.groovy
, are there other places?
Also, is it possible for me to define my own environment, e.g. PRE_PRODUCTION
, such that it will work with the closures above and the -Denv
flag?
Finally, can the CUSTOM
environment be used with the -Denv
flag?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…