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:

Giới thiệu Google Guice – Dependency injection (DI) framework
Java Program to Implement the Schonhage-Strassen Algorithm for Multiplication of Two Numbers
Quick Guide to Spring MVC with Velocity
Static Content in Spring WebFlux
Apache Camel with Spring Boot
How to Return 404 with Spring WebFlux
Configure a RestTemplate with RestTemplateBuilder
Java Program to Perform Deletion in a BST
A Guide to WatchService in Java NIO2
Java Program to Implement Sorted Array
Java – Reader to InputStream
Java Program to Implement Dijkstra’s Algorithm using Priority Queue
Java Program to Implement Gift Wrapping Algorithm in Two Dimensions
Java Program to Perform Polygon Containment Test
How to Manually Authenticate User with Spring Security
Java Program to Describe the Representation of Graph using Incidence List
ClassNotFoundException vs NoClassDefFoundError
Java Program to Implement Hash Tables Chaining with Doubly Linked Lists
Java Program to Implement ArrayList API
Spring Boot with Multiple SQL Import Files
Hướng dẫn sử dụng Lớp FilePermission trong java
Java Program to Check Whether Topological Sorting can be Performed in a Graph
Java Program to Create a Balanced Binary Tree of the Incoming Data
Spring Boot - Exception Handling
Java Program to Implement Word Wrap Problem
Java Program to Solve Set Cover Problem assuming at max 2 Elements in a Subset
Spring Boot - Eureka Server
Java Program to Represent Graph Using Adjacency List
Java Program to Implement Merge Sort Algorithm on Linked List
Hướng dẫn sử dụng String Format trong Java
Java Program to Implement Hash Tables Chaining with List Heads
Java Program to Implement Ternary Tree