As said in docs either set server.port as system property using command line option to jvm -Dserver.port=8090 or add application.properties in /src/main/resources/ with
server.port=8090
For a random port use:
server.port=0
Similarly add application.yml in /src/main/resources/ with:
server:
port: 8090
Answer from Paul Verest on LinkedIn on Stack OverflowAs said in docs either set server.port as system property using command line option to jvm -Dserver.port=8090 or add application.properties in /src/main/resources/ with
server.port=8090
For a random port use:
server.port=0
Similarly add application.yml in /src/main/resources/ with:
server:
port: 8090
There are two main ways to change the port in the Embedded Tomcat in a Spring Boot Application.
Modify application.properties
First you can try the application.properties file in the /resources folder:
server.port = 8090

Modify a VM option
The second way, if you want to avoid modifying any files and checking in something that you only need on your local, you can use a vm arg:
Go to Run -> Edit Configurations -> VM options
-Dserver.port=8090

Additionally, if you need more information you can view the following blog post here: Changing the port on a Spring Boot Application