how to change default port in spring boot

To change the default port in a Spring Boot application, follow these steps:

  1. Open the application.properties file in your project's src/main/resources directory. If the file doesn't exist, create it.

  2. Add the following line to the application.properties file: server.port=8081 Replace 8081 with the desired port number you want to use.

  3. Save the application.properties file.

  4. Restart your Spring Boot application for the changes to take effect.

By adding the server.port property in the application.properties file and specifying the desired port number, you can change the default port used by the Spring Boot application.