Spring Boot – Tomcat Port Number

Table of Contents

Spring Boot lets you to run the same application more than once on a different port number. In this chapter, you will learn about this in detail. Note that the default port number 8080.

1. Custom Port

In the application.properties file, we can set custom port number for the property server.port

server.port = 9090

In the application.yml file, you can find as follows −

server: 
   port: 9090

Random Port

In the application.properties file, we can set random port number for the property server.port

server.port = 0

In the application.yml file, you can find as follows −

server: 
   port: 0

Note − If the server.port number is 0 while starting the Spring Boot application, Tomcat uses the random port number.

Related posts:

Introduction to Spring Data JPA
Spring Cloud AWS – Messaging Support
Java Program to Perform Uniform Binary Search
Checked and Unchecked Exceptions in Java
Spring’s RequestBody and ResponseBody Annotations
StringBuilder vs StringBuffer in Java
Java Program to Implement Tarjan Algorithm
Java Program to Compute Cross Product of Two Vectors
Java Program to Perform Searching in a 2-Dimension K-D Tree
Java Program to Solve Travelling Salesman Problem for Unweighted Graph
Java Program to Perform Right Rotation on a Binary Search Tree
Immutable Objects in Java
Java Program to Use the Bellman-Ford Algorithm to Find the Shortest Path
Java Program to Implement Maximum Length Chain of Pairs
Java Convenience Factory Methods for Collections
Spring Boot - Cloud Configuration Server
How to Store Duplicate Keys in a Map in Java?
Java Program to Perform Searching Using Self-Organizing Lists
How to Kill a Java Thread
What is Thread-Safety and How to Achieve it?
Java Program to Implement Fermat Factorization Algorithm
Java Program to Check Whether a Given Point is in a Given Polygon
Java Program to Implement AttributeList API
New Features in Java 11
How to Convert List to Map in Java
Java – File to Reader
OAuth2 for a Spring REST API – Handle the Refresh Token in AngularJS
Introduction to the Java NIO Selector
Java Program to find the peak element of an array using Binary Search approach
Send email with authentication
Java Program to Implement Repeated Squaring Algorithm
Introduction to the Functional Web Framework in Spring 5