Spring-boot – Spring Boot: Change Port for Web Application


I am currently trying to create a web application with Spring Boot. I need to host my application to localhost:8081. How do I change the port?

Best Solution

Actually you want to change server.port and you can change it in many different ways as described http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-external-config


  • in your application.properties (in or outside the jar)
  • command line

    java -Dserver.port=$PORT -jar target/demo-0.0.1-SNAPSHOT.jar

and much more