Explore Courses Blog Tutorials Interview Questions
0 votes
in Java by (830 points)
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.

1 Answer

0 votes
by (13.2k points)

There are many ways to change the default port which are given as follows:


1.You can set port in java code:

HashMap<String, Object> props = new HashMap<>(); props.put("server.port", 9999);

new SpringApplicationBuilder() 




Note:  Using the HashMap will work only if no port is set in or .yml.

2. In application.yml:

 server: port: 9999

    Or in


3. As a command line parameter:


Browse Categories