In our environment, the port the server listens is always specified by a command line parameter:
java -jar myweb.jar --server.port=1024
.
How can we get this value? In my AppSiteController.java
I tried to use:
@Value("${server.port}")
private static String serverPort;
public static void main(String[] args) {
System.out.println(serverPort);
SpringApplication.run(AppSiteController.class, args);
}
Which returns null when the value is correctly specified on the command line.
Thanks.