How to configure port for a Spring Boot application

0 votes
Hii team,

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.
May 22, 2020 in Java by kartik
• 37,520 points
2,988 views

1 answer to this question.

0 votes

Hello @kartik,

You can set port in java code:

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

new SpringApplicationBuilder()
    .sources(SampleController.class)                
    .properties(props)
    .run(args);

Or in application.yml:

server:
    port: 9999

Or in application.properties:

server.port=9999

Or as a command line parameter:

-Dserver.port=9999

Hope this works!!

Get your Spring Certification today to become certified.

answered May 22, 2020 by Niroj
• 82,840 points

Related Questions In Java

0 votes
3 answers

How to check whether a string is empty or not? Is there a function for this?

str != null && str.length() != 0 alternatively str ...READ MORE

answered Sep 11, 2018 in Java by Sushmita
• 6,920 points
1,432 views
0 votes
1 answer

How to configure Android SDK for finding JDK

Actual SETUP: OS: Windows 8.1 JDK file: jdk-8u11-windows-x64.exe ADT file: ...READ MORE

answered Jun 29, 2018 in Java by Rishabh
• 3,620 points
799 views
0 votes
1 answer

How to download a file from spring controllers?

@RequestMapping(value = "/files/{file_name}", method = RequestMethod.GET) public void ...READ MORE

answered Sep 4, 2018 in Java by code.reaper12
• 3,500 points
2,948 views
0 votes
2 answers

How to log SQL statements in Spring Boot?

HI.. try using this in your properties file: logging.level.org. ...READ MORE

answered Sep 25, 2020 in Java by SRI

edited Sep 25, 2020 by Sirajul 4,932 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,434 views
0 votes
1 answer
0 votes
1 answer

How to set base url for rest in spring boot?

Hello @kartik, Set it up in your application.yml ...READ MORE

answered May 22, 2020 in Java by Niroj
• 82,840 points
14,380 views
0 votes
1 answer

How to determine programmatically the current active profile using Spring boot ?

Hello, It doesn't matter is your app Boot ...READ MORE

answered May 21, 2020 in Java by Niroj
• 82,840 points

edited Mar 4, 2022 by Sarfaraz 8,204 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP