How to make Bootstraping environment specific in a Grails app?

03 / Jun / 2008 by Deepak 0 comments

BootStraping is something which is needed in most of the grails application. One of the frequently asked questions (and a valid requirement as well) is : How do you make Bootstraping happen only in a particular environment.

This can be done by making use of one of the Grails utility class which allows you to inspect the environment in which the code is executing.

Example:

if (GrailsUtil.environment == GrailsApplication.ENV_DEVELOPMENT) {

// Your bootstraping code here.

}

Don’t forget to import the following two classes:

org.codehaus.groovy.grails.commons.GrailsApplication
grails.util.GrailsUtil

Hope this little tips saves you some time.

FOUND THIS USEFUL? SHARE IT

Tag -

Grails Groovy

Leave a Reply

Your email address will not be published. Required fields are marked *