Spring Boot:更改 Web 应用程序的端口 [英] Spring Boot: Change Port for Web Application
本文介绍了Spring Boot:更改 Web 应用程序的端口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我目前正在尝试使用 Spring Boot 创建 Web 应用程序.我需要将我的应用程序托管到 localhost:8081.如何更改端口?
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?
推荐答案
实际上你想改变 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
还有更多
这篇关于Spring Boot:更改 Web 应用程序的端口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文