How to Solve in Grails 2.x: ConfigurationHolder.getConfig() is Deprecated

With the newer Grails version 2.x, ConfigurationHolder is marked as deprecated.

In Grails apps ver. < 2.0, you can access your configuration properties:

// BootStrap.groovy

import org.codehaus.groovy.grails.commons.ConfigurationHolder as CH
class BootStrap {
   // e.g.: def <propertyValue> = CH.<property>
   def serverURL = CH.grails.serverURL

To avoid the deprecated class ConfigurationHolder in Grails ver. >= 2.0, use the following dependency injection grailsApplication:

// BootStrap.groovy

class BootStrap {
   def grailsApplication

   def init = {servletContext ->
       // e.g.: def <propertyValue> = grailsApplication.config.<property>
      def serverURL = grailsApplication.config.grails.serverURL

Custom properties can be defined in Config.groovy:

// Config.groovy
environments {
   development {
     grails.serverURL = "http://localhost:8080/${appName}"

   production {
      grails.serverURL = ""
This entry was posted in Development, Grails and tagged , . Bookmark the permalink.

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.