簡體   English   中英

在guice模塊中獲取運行Play微服務的端口

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM