How do I get at the goodies in my Grails Config.groovy at runtime?

后端 未结 4 1085
慢半拍i
慢半拍i 2020-12-13 00:32

in Config.groovy I see this:

// set per-environment serverURL stem for creating absolute links
environments {
    production {
        grails.serverURL = \"h         


        
4条回答
  •  甜味超标
    2020-12-13 00:53

    As mentioned in a few of the comments, another option is the grails.utils.Holders class which was added in Grails 2.0. I prefer this approach since you can use it in classes that aren't configured with dependency injection.

    import grails.util.Holders
    
    class Foo {
        def bar() {
            println(Holders.config.grails.serverURL)
        }
    }
    

提交回复
热议问题