Start Spring Boot App on a Different Port Number

In this tutorial, you will learn how to start your Spring Boot Web application on a different port number.

By default, if no port number is configured, our Spring Boot Web application will start on port number 8080. To configure a different port number, you will need to update an file with the following configuration property.

server.port = <port number here>

For example, to make my Spring Boot application startup on port number 8010, I will update the file in my Spring Boot application with the following configuration property.

server.port = 8010

Set Port Number via Command-line Argument

You can also override the configured port number in your Spring Boot application by setting it via a command-line argument. Below is an example of how you can start up your Spring Boot application and set the server.port number property via a command-line argument.

mvn spring-boot:run

You can also start your Spring Boot application using a java -jar command.

mvn package
java -jar target/<FILENAME.JAR HERE> --server.port=8010

Video Tutorial

I hope this tutorial was helpful to you. I also have many short Spring Boot video tutorials here: Spring Boot and Spring MVC tutorials.

Happy learning!

Leave a Reply

Your email address will not be published.