简体   繁体   中英

Grails - How can I get serverURL in config.groovy?

I want to use ServerURL in config.groovy .

But, I need configure url.setting both development and production if I cannot use serverURL in config.groovy .

I try to get serverURL like below, it makes error.

config.groovy

def grailsApplication
environments {
    development {
        grails.logging.jul.usebridge = true
        grails.serverURL = "http://localhost:8080"
    }
    production {
        grails.logging.jul.usebridge = false
        grails.serverURL = "http://myapp.com"
    }
}
url.setting = "${grailsApplication.config.grails.serverURL}"

the error when I run app is like below

Error Error packaging application: Error loading Config.groovy: Cannot get property 'config' on null object (Use --stacktrace to see the full trace)

您可以通过以下方式获取服务器网址:

url.setting="${grails.serverURL}"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM