且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Spring Boot:更改 Web 应用程序的端口

更新时间:2023-01-09 23:29:45

实际上你想改变 server.port 并且你可以按照 http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-external-config

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

示例:

  • 在您的 application.properties 中(在 jar 内或外)
  • 命令行

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

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

还有更多