Spring Boot - How to get the running port
问题 I have a spring boot application (using embedded tomcat 7), and I\'ve set server.port = 0 in my application.properties so I can have a random port. After the server is booted up and running on a port, I need to be able to get the port that that was chosen. I cannot use @Value(\"$server.port\") because it\'s zero. This is a seemingly simple piece of information, so why can\'t I access it from my java code? How can I access it? 回答1: Is it also possible to access the management port in a similar