HiveBrain v1.2.0
Get Started
← Back to all entries
snippetjavaspringCritical

How to configure port for a Spring Boot application

Submitted by: @import:stackoverflow-api··
0
Viewed 0 times
porthowforspringconfigureapplicationboot

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.

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

Code Snippets

server.port=8090
server.port=0
server:
  port: 8090

Context

Stack Overflow Q#21083170, score: 1637

Revisions (0)

No revisions yet.