how to change spring boot port number

Ads
 

how to change spring boot port number

Hi,

I have a web application developed in Spring boot which is running on port number 8080. I have to change the port number of the application to say 8084. How I can change the spring boot web application?

Do I need to install the application in separate tomcat server running on port number 8084?

Provide me easy steps to do the same.

Thanks

View Answers

October 2, 2020 at 12:20 PM

HI,

By default Spring Boot application runs on the embedded tomcat server and comes with the default configuration. By default spring boot web application runs on 8080 port.

The easiest way is to change the default configuration and update it to instruct Spring boot to run application on some other port say 8084.

If you are using application.properties in your application then add the following configuration:

server.port=8084

If you are using application.yml file in your project then add following in the application.xml file:

server:
  port : 8084

Above change will instruct Spring Boot to run the web application on port number 8084. This way you can change spring boot default port 8080 to new port 8084.

Hope this helps you.

Thanks


October 2, 2020 at 12:24 PM

HI,

You can also change the configuration grammatically. Here is simple example of configuration:

@SpringBootApplication
public class MyWebApplication {
    public static void main(String[] args) {
        SpringApplication app = new SpringApplication(MyWebApplication.class);
        app.setDefaultProperties(Collections
          .singletonMap("server.port", "8084"));
        app.run(args);
    }
}

Above example will instruct the application to run on 8084 port.

Thanks


October 2, 2020 at 12:26 PM

Hi,

You will find more tutorials at:

Thanks


October 15, 2020 at 8:02 AM

Hi

There are options to change the port number of tomcat from command line also. While running the jar file with java -jar command you can provide configuration to run Spring web application on other port also.

Here is example command:

java -jar myapp.jar --server.port=8083

or

java -jar -Dserver.port=8083 myapp.jar

Hope this helps you.

Thanks

Ads









Related Tutorials/Questions & Answers:
how to change spring boot port number
how to change spring boot port number  Hi, I have a web application developed in Spring boot which is running on port number 8080. I have to change the port number of the application to say 8084. How I can change the spring boot
MySQL default port number and how to change it
MySQL default port number and how to change it What is default port number... and how to change it?" The MySQL default port number 3306. Here... the port number in your program. You can also change the port number of MySQL
Advertisements
How to change MySQL default port Windows?
How to change MySQL default port Windows?  Hi, I am learning JDBC... of MySQL. How to change MySQL default port Windows? Thanks   Hi... tutorials of MySQL Server: MySQL Tutorials MySQL default port number and how
How to change MySQL default port Windows?
How to change MySQL default port Windows?  Hi, I am learning JDBC... of MySQL. How to change MySQL default port Windows? Thanks   Hi... tutorials of MySQL Server: MySQL Tutorials MySQL default port number and how
How to change default MySQL port in linux?
How to change default MySQL port in linux?  I have a sever and due to some reasons I want to run the MySQL server on the different port and not on the detault port 3306. How to change the MySQL default port on my Linux box
Changing MySQL Port Number
Changing MySQL Port Number  How to change the MySQL port... installation directory. Change the port number to desired port number. By default port... to the desired port number. After making change in my.ini file save the file
How long will it take to learn Spring boot
to learn it quickly. How long will it take to learn Spring boot? How much time...How long will it take to learn Spring boot  Hi, These days most of the Java enterprise project is shifting to the Spring Boot. This skill
How long will it take to learn Spring boot
to learn it quickly. How long will it take to learn Spring boot? How much time...How long will it take to learn Spring boot  Hi, These days most of the Java enterprise project is shifting to the Spring Boot. This skill
MySQL default port number in Linux
MySQL default port number and how to change it MySQL Tutorial JDBC...MySQL default port number in Linux - How to find the default port number... is for you. In this tutorial you learn "How to find the default port number
MySQL Default Port number
MySQL Default Port number  HI, What is MySQL Default Port number? Thanks   Hello, MySQL Server Default Port number is 3306. Thanks
mysql port number other than 3306
mysql port number other than 3306  Hi, Can I change MySQL port number? What can be mysql port number other than 3306? Thanks
mapr drill port number
mapr drill port number  Hi, What is the port number in Mapr for accessing Apache drill? I want to know all the mapr drill port numbers. Thanks   Hi, Here is the list of all the port of drill in mapr: Port Type
mapr drill port number
mapr drill port number  Hi, What is the port number in Mapr for accessing Apache drill? I want to know all the mapr drill port numbers. Thanks   Hi, Here is the list of all the port of drill in mapr: Port Type
Simple Spring Boot Example
: How to import existing maven project in Eclipse? Step 2: Add Spring Boot...Simple Spring Boot Example - First example of Spring Boot for counting no of beans Spring Boot Simple Example, writing and running the first example code
Simple Spring Boot Example
: How to import existing maven project in Eclipse? Step 2: Add Spring Boot...Simple Spring Boot Example - First example of Spring Boot for counting no of beans Spring Boot Simple Example, writing and running the first example code
spring boot 2.2.0 maven dependency
spring boot 2.2.0 maven dependency  Hi, I have spring boot old application and now I want to upgrade it to new version of Spring boot. For this I have to change version entry in pom.xml file. How to upgrade it to latest version
Is spring boot easy to learn
Is spring boot easy to learn  Hi, I am a software developer... company and they have told me to work learn Spring/Spring Boot. From Next month I have to work on Spring and Spring boot project. So, I have only 1 month time
Is spring boot easy to learn
Is spring boot easy to learn  Hi, I am a software developer... company and they have told me to work learn Spring/Spring Boot. From Next month I have to work on Spring and Spring boot project. So, I have only 1 month time
hibernate.archive.autodetection spring boot
hibernate.archive.autodetection spring boot  Hi, How to use hibernate.archive.autodetection option in spring boot? Thanks   Hi...   Hi, Do you want to learn Spring Boot for your next project? Check
spring boot 2.3.1 dependencies
spring boot 2.3.1 dependencies  Hi, There is latest release of Spring boot 2.3.1 and I want to use the same in my project. What is the spring boot 2.3.1 dependencies? I want to try Spring boot 2.3.1 so I need the maven
spring boot webflux dependency
spring boot webflux dependency  Hi, I want to use the webflux in spring boot application. What is the code for adding in pom.xml file? I need pom.xml code for spring boot webflux dependency. Thanks   HI, You can use
What is the best way to learn spring boot
What is the best way to learn spring boot  Hi, I have some experience of working with Spring Core and Spring Web. I want to learn Spring Boot. How anyone can learn the Spring Boot Framework? What is the best way to learn spring
What is the best way to learn spring boot
What is the best way to learn spring boot  Hi, I have some experience of working with Spring Core and Spring Web. I want to learn Spring Boot. How anyone can learn the Spring Boot Framework? What is the best way to learn spring
Spring Boot Console Application
Spring Boot Tutorial- Spring Boot Console Application Welcome to the first example of Spring Boot, today we will teach you to create your first application in Spring Boot. As you already know you can create console and web
Spring Boot Console Application
Spring Boot Tutorial- Spring Boot Console Application Welcome to the first example of Spring Boot, today we will teach you to create your first application in Spring Boot. As you already know you can create console and web
ModuleNotFoundError: No module named 'plaster-spring-boot'
named 'plaster-spring-boot' How to remove the ModuleNotFoundError: No module named 'plaster-spring-boot' error? Thanks   Hi...ModuleNotFoundError: No module named 'plaster-spring-boot'  Hi, My
ModuleNotFoundError: No module named 'plaster-spring-boot'
named 'plaster-spring-boot' How to remove the ModuleNotFoundError: No module named 'plaster-spring-boot' error? Thanks   Hi...ModuleNotFoundError: No module named 'plaster-spring-boot'  Hi, My
Low port Scanner
Low port Scanner       In this section, you will learn how to get local port number... the massage on the command line very low port information. The java.net package
Spring Boot Web Starter 2.1.1 Maven dependency
Spring Boot Web Starter 2.1.1 Maven dependency  Hi, I want to use Spring Boot Web Starter 2.1.1 in my spring boot application. My application is based on the old version of Spring Boot. Now will use Spring Boot Web Starter 2.1.1
Version of org.springframework.boot>spring-boot-starters dependency
List of Version of org.springframework.boot>spring-boot-starters dependency
Version of cn.kxlove>spring-boot-beetl dependency
List of Version of cn.kxlove>spring-boot-beetl dependency

Ads