Why are there two names for the port ?
server.port=..
and
local.server.port
What is the difference between them?
Localhost is the default name used to establish a connection with a computer. The IP address is usually 127.0. 0.1. This is done by using a loopback address network. Port 80 is the common standard port for HTTP.
The Spring Boot framework provides the default embedded server (Tomcat) to run the Spring Boot application. It runs on port 8080.
The fastest and easiest way to customize Spring Boot is by overriding the values of the default properties. For the server port, the property we want to change is server. port. By default, the embedded server starts on port 8080.
To get the server address you can use the InetAddress class to get the local ip-address, for the port you can use ${server. port:8080} is you are using tomcat (this trick would also work for the server.
server.port
is a way to define a value for the tomcat port of your service. It is used in "application.properties" file. If you do not fix this property, the port 8080 is chosen by default.
local.server.port
is used to recover the value of the running port. It is used in the code like that:
@Value("${local.server.port}")
int runningPort;
or like that too:
@LocalServerPort
int runningPort;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With