How to configure port for a Spring Boot application

Paul Verest picture Paul Verest · Jan 13, 2014 · Viewed 778.6k times · Source

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.

Answer

Paul Verest picture Paul Verest · Jan 13, 2014

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 random port use

server.port=0

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

server:
  port : 8090