2

I am using grails 2.0.4 and would like to refer to configuration information in my resources.groovy file. In earlier versions of grails, I used ConfigurationHolder to get at this information, but this is now deprecated.

From reading other posts, I am confused about how to proceed. One suggests that the property application will get injected with the GrailsApplication bean; another suggests the use of grailsApplication, but neither seems to work in my resources.groovy file.

Must I load the GrailsApplication bean "manually" as stated here? Or is there a more elegant solution? An example of a working resource file that accesses configuration information would be great.

Community
  • 1
  • 1
Gene Golovchinsky
  • 6,101
  • 7
  • 53
  • 81

2 Answers2

10

What did work for me was:

application.config.my.etc

I didn't even had to def application nor grailsApplication

(grailsApplication didn't work for me either)

Johnny C.
  • 368
  • 1
  • 5
  • 20
1

I think this post already answers your question:

// resources.groovy
beans = {
    grailsApplication = ref('grailsApplication')
    // So from here you could use grailsApplication to access the config object (e.g. grailsApplication.config.defaultFolder
}

Regards,

Luismy

Community
  • 1
  • 1
luismy
  • 71
  • 5