Without configuring the JVM startup parameter:
-Dgrails.env=whatever
Your grails application will use the value set to
<yourapp>/WEB-INF/classes/application.properties
A value similar to this will be set:
grails.env=development
This default value for the environment is determined by what parameters are used in the construction of the war. You can build a war with
-Dgrails.env=development war
Then in application.properties will have grails.env = development, if you leave this, the default value is grails.env = production
As for your question, you do not know what is configured to use "environment-specific URLs". And it's not clear how you store these environment-specific URLs. If, for example, the URL variable is a Grails member variable and you store environment-specific URLs in Config.groovy, then you can
import grails.util.Environment ... //inject the GrailsApplication Configuration in Config.groovy def grailsApplication //Hold the URL value from Config.groovy String environmentUrl ... Environment current = Environment.getCurrent() if(Environment.PRODUCTION == current) { environmentUrl = grailsApplication.config.PRODUCTION_URL } else { environmentUrl = grailsApplication.config.DEVELOPMENT_URL }
Where Config.groovy has
PRODUCTION_URL = "http://blah.com/blah/" DEVELOPMENT_URL = "http://blah.dev/blah"
Hope this helps.
source share