简体   繁体   中英

Config grails.serverURL Get Dynamic Port

In my Config.groovy file, I have the grails.serverURL set for development, but the port is hard-coded to 8080.

A few developers, have different ports configured to prevent other running apps from conflicting (local-dev SOA for example).

What I've tried hasn't given me happy results.

  1. I set the -Dserver-port=8090 in my run-app command
  2. Referenced both ${server.port} and ${grails.server.port.http} in the grails.serverURL string

How can I reference the -Dserver-app value for use in the Config.groovy?

you can access your system properties using System.getProperty()

For example, run your grails app with:

grails -Dserver-app="foobar" run-app

Then in Config.groovy:

def ServerApp = System.getProperty("server-app"); //returns "foobar"

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