使用Play Framework在应用程序中检索端口号 [英] Retrieving port number in-application using Play Framework

查看:58
本文介绍了使用Play Framework在应用程序中检索端口号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的系统上有两个运行在端口9001和9002上的Play框架Web应用程序.我想知道是否有什么方法可以从Java代码中检索它们在哪个端口上运行.

I have two Play framework web applications running on my system on ports 9001 and 9002. I was wondering if there was any way I could retrieve which port they were running on from within my Java code.

这可能吗?

推荐答案

是.您可以这样获得端口:

Yes. You can get the port like this:

int port = Integer.parseInt(Play.configuration.getProperty("http.port", 9000));

当然,您必须导入类play.Play.

这篇关于使用Play Framework在应用程序中检索端口号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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