[英]Get Port of running play microservice within a guice module
我想在一個隨機端口(端口0)上啟動一個播放應用程序。 每個啟動的微服務實例都應連接到服務定位器(eureka),並告訴他他的端口和主機。 但是,如何獲取正在運行的播放服務的端口?
這個問題實際上被問過幾次,但是答案對我不起作用:
class MyModule @Inject() (configuration: Configuration) extends AbstractModule {
configuration.getInt("http.port") // returns None
System.getProperty("http.port") // returns null
}
根據播放文檔,這應該起作用:
configuration.get[Int]("play.server.http.port")
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.