How do I configure the TCP/IP port listened on by a Spring Boot application, so it does not use the default port of 8080.
Usually, the most straightforward way to configure the HTTP port of a Spring Boot application is by defining the port in the configuration file application. properties or application. yml. Next, let's go through the two scenarios and discuss different ways to get the port programmatically at runtime.
By default, Spring Boot uses the 8080 port number to start the Tomcat.
Method 1: By Adding the configuration in the application properties of the Spring Boot project. We need to change the port number using the application. properties file in the project structure of the spring application.
As said in docs either set server.port
as system property using command line option to jvm -Dserver.port=8090
or add application.properties
in /src/main/resources/
with
server.port=8090
For random port use
server.port=0
Similarly add application.yml
in /src/main/resources/
with
server: port : 8090
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