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
I used to declare the configuration in application.properties like this (you can use you own property file)
server.host = localhost
server.port = 8081
and in application you can get it easily by @Value("${server.host}") and @Value("${server.port}") as field level annotation.
or if in your case it is dynamic than you can get from system properties
Here is the example
@Value("#{systemproperties['server.host']}")
@Value("#{systemproperties['server.port']}")
For a better understanding of this annotation , see this example Multiple uses of @Value annotation