如何在运行时获取Grails Config.groovy中的好东西? [英] How do I get at the goodies in my Grails Config.groovy at runtime?

查看:177
本文介绍了如何在运行时获取Grails Config.groovy中的好东西?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Config.groovy中我看到了:

in Config.groovy I see this:

// set per-environment serverURL stem for creating absolute links
environments {
    production {
        grails.serverURL = "http://www.changeme.com"
    }
}

在运行时正确的方法是什么?

what is the correct way to access that at runtime?

推荐答案

danb在正确的轨道上。然而,如果你做一个更好的导入,生活变得更容易手指:

danb is on the right track. However, life gets a bit easier on your fingers if you do a nicer import:

import org.codehaus.groovy.grails.commons.ConfigurationHolder as CH
println CH.config.grails.serverURL

这篇关于如何在运行时获取Grails Config.groovy中的好东西?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆