Spring Boot: Change Port for Web Application

后端 未结 6 1760
无人共我
无人共我 2021-02-20 08:41

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?

6条回答
  •  迷失自我
    2021-02-20 09:36

    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

    Examples:

    • 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

提交回复
热议问题