Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure port for a Spring Boot application

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.

like image 559
Paul Verest Avatar asked Jan 13 '14 02:01

Paul Verest


People also ask

How do I get spring boot port?

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.

What port does spring boot use?

By default, Spring Boot uses the 8080 port number to start the Tomcat.

Can we change port number in spring boot?

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.


1 Answers

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 
like image 145
Paul Verest Avatar answered Oct 22 '22 13:10

Paul Verest