I\'m starting up a Spring Boot application with mvn spring-boot:run.
One of my @Controllers needs information about the host and port the a
You can get network interfaces with NetworkInterface.getNetworkInterfaces(), then the IP addresses off the NetworkInterface objects returned with .getInetAddresses(), then the string representation of those addresses with .getHostAddress().
If you make a @Configuration class which implements ApplicationListener, you can override onApplicationEvent to get the port number once it's set.
@Override
public void onApplicationEvent(EmbeddedServletContainerInitializedEvent event) {
int port = event.getEmbeddedServletContainer().getPort();
}