There should be a straightforward way to do this, but most answers on the net provide the port of an embedded Tomcat server using something like ${server.port}
(or its equivalent). Other solutions mention listening to EmbeddedServletContainerInitializedEvent
but this also is only applicable to embedded web servers.
How can I obtain the port of an application that's deployed on (let's say) JBoss
where the port is decided through the server's own configuration file (and not through application.properties)?
(P.S: In Spring Boot 2, there is an event called WebServerInitializedEvent
, using which we can probably get the true port, but I'm looking for solutions up to Spring Boot 1.5.8
)