how to change the tomcat port in spring boot

To change the port of a Spring Boot application running on Tomcat, you can follow these steps:

Step 1: Open the file

In your Spring Boot project, locate the file. This file is typically located in the src/main/resources directory.

Step 2: Add the port configuration

Inside the file, add the following line to configure the port:


Replace 8081 with the desired port number you want to use for your application.

Step 3: Save the changes

Save the file.

Step 4: Run the application

Now, when you run your Spring Boot application, it will use the specified port. You can access your application using the new port number.

Please note that these steps assume you are using the default embedded Tomcat server provided by Spring Boot. If you are using a different server, the configuration steps may vary.