How to configure port for a Spring Boot application

java, port, server, spring, spring-boot

Solution

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

Problem

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.

Original source

Related problems