[英]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. 在我的Config.groovy文件中,我将grails.serverURL设置为开发,但端口硬编码为8080。
A few developers, have different ports configured to prevent other running apps from conflicting (local-dev SOA for example). 一些开发人员配置了不同的端口以防止其他正在运行的应用程序发生冲突(例如本地开发SOA)。
What I've tried hasn't given me happy results. 我试过的并没有给我带来快乐的结果。
-Dserver-port=8090
in my run-app command -Dserver-port=8090
${server.port}
and ${grails.server.port.http}
in the grails.serverURL string ${server.port}
和${grails.server.port.http}
How can I reference the -Dserver-app
value for use in the Config.groovy? 如何引用
-Dserver-app
值以在Config.groovy中使用?
you can access your system properties using System.getProperty() 您可以使用System.getProperty()访问您的系统属性
For example, run your grails app with: 例如,运行您的grails应用程序:
grails -Dserver-app="foobar" run-app
Then in Config.groovy: 然后在Config.groovy中:
def ServerApp = System.getProperty("server-app"); //returns "foobar"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.