Change the Server’s Port Number and Context Path

  • We can change the port number in application.properties file. The change can happen during development.
  • Also, we can change the default port number of the server along with the context path using the command line. This happens when the application is in a running state or we can say after development.

Default port number: 8080
Default Context path: ‘/’

Interfaces and Properties files:

We can change the default port number for embedded server in Spring Boot application using the below interfaces and properties files:

  • application.properties
  • application.yml
  • Command-Line Interface
  • WebServerFactoryCustomizer Interface
  • EmbeddedServletContainer Interface

How to Change the Default Port in Spring Boot?

Spring Boot framework provides a default embedded server i.e. the Tomcat server for many configuration properties to run the Spring Boot application. The application runs on the default port which is 8080. As per the application need, we can also change this default port for the embedded server. In this article, we will discuss how to change the default port number in the Spring Boot application.

Similar Reads

What is PortNumber?

The port number helps to provide various kinds of services port number 80 always goes to the HTTP services but at a one-time only one service at a time. So, we have to change the default port number. Let’s discuss how to change the port number....

Change the Server’s Port Number and Context Path

We can change the port number in application.properties file. The change can happen during development.Also, we can change the default port number of the server along with the context path using the command line. This happens when the application is in a running state or we can say after development....

Step By Step Implementation to change the default port in Spring Boot

Go to Spring InitializrFill in the details as per the requirementsClick on Generate which will download the starter projectExtract the zip file...