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:

Java Program to Implement RenderingHints API
Converting String to Stream of chars
Comparing getPath(), getAbsolutePath(), and getCanonicalPath() in Java
Java Program to Implement Stack using Linked List
Java Program to Implement the Hungarian Algorithm for Bipartite Matching
Registration with Spring Security – Password Encoding
Kiểu dữ liệu Ngày Giờ (Date Time) trong java
Java 8 – Powerful Comparison with Lambdas
Spring Boot - Hystrix
Java Program to Implement Binomial Tree
Java Program to Implement ConcurrentSkipListMap API
Java Program to Check whether Undirected Graph is Connected using BFS
Java Program to Implement Skip List
Guide to the ConcurrentSkipListMap
Java Program to Implement ScapeGoat Tree
Spring Data Reactive Repositories with MongoDB
Simple Single Sign-On with Spring Security OAuth2
Giới thiệu Google Guice – Injection, Scope
Java String to InputStream
Java Program to Implement Tarjan Algorithm
Getting Started with Stream Processing with Spring Cloud Data Flow
Spring MVC Custom Validation
Converting a Stack Trace to a String in Java
Java Program to Implement Quick Sort with Given Complexity Constraint
Java Program to Check Whether an Input Binary Tree is the Sub Tree of the Binary Tree
Spring Security OAuth2 – Simple Token Revocation
Join and Split Arrays and Collections in Java
Java Program to Generate a Graph for a Given Fixed Degree Sequence
Spring Boot - Eureka Server
Java Program to Solve Travelling Salesman Problem for Unweighted Graph
Spring Boot - Tracing Micro Service Logs
Spring Boot With H2 Database