How to configure port for a Spring Boot application

To configure the TCP/IP port used by a Spring Boot application, you can specify the server.port property in the application.properties file or the application.yml file.

Here’s how to set the port to 9000 using the application.properties file:

1. Create a file named application.properties in the src/main/resources directory of your project.

2. Add the following line to the file:

server.port=9000

This sets the TCP/IP port to 9000. You can replace 9000 with any valid port number.

Here’s how to set the port to 9000 using the application.yml file:

1. Create a file named application.yml in the src/main/resources directory of your project.

Add the following lines to the file:

server:
  port: 9000

This sets the TCP/IP port to 9000.

Once you have made the changes to the application.properties or application.yml file, Spring Boot will automatically pick up the new configuration the next time you run your application. If you have already started your Spring Boot application, you will need to stop and restart it for the new port configuration to take effect.

How to configure port for a Spring Boot application
Scroll to top