The easiest way to configure port for a spring boot application

Spring boot web application runs on a default localhost port 8080 which can be changed or configured in many easy ways.

Using Configuration Files:

We can easily configure the port of the spring boot application using the file or the application.yml file.

for we can configure like:


for application.yml we can configure like:

  port: 9292

Configuration programmatically using Java :

When we start a spring boot project is executed and in that very class we can configure the server port programmatically

Below lines of Codes are used to do the above-given configuration.


import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

public class SmartcontactmanagerApplication {

  public static void main(String[] args) {, args);


This is how you can configure the server port in two easy ways.

Leave a Reply

Your email address will not be published. Required fields are marked *