How to configure port for a Spring Boot application

2021-6-3 anglehua

How do I configure the TCP/IP port listened on by a Spring Boot application, so it does not use the default port of 8080.

As said in docs either set server.port as system property using command line option to jvm -Dserver.port=8090 or add in /src/main/resources/ with


For random port use


Similarly add application.yml in /src/main/resources/ with

  port : 8090

There are two main ways to change the port in the Embedded Tomcat in a Spring Boot Application.


First you can try the file in the /resources folder:

server.port = 8090 file

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


Change port with a vm arg

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


Powered by emlog 京ICP备15036472号-3 sitemap