如何为 Spring Boot 应用程序配置端口 [英] How to configure port for a Spring Boot application
本文介绍了如何为 Spring Boot 应用程序配置端口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何配置 Spring Boot 应用程序侦听的 TCP/IP 端口,使其不使用默认端口 8080.
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.
推荐答案
As 在文档中说 要么使用 jvm 的命令行选项将 server.port
设置为系统属性 -Dserver.port=8090
或在 /src/main/resources/
中添加 application.properties
和
As said in docs either set server.port
as system property using command line option to jvm -Dserver.port=8090
or add application.properties
in /src/main/resources/
with
server.port=8090
随机端口使用
server.port=0
同样在/src/main/resources/
中添加application.yml
和
server:
port : 8090
这篇关于如何为 Spring Boot 应用程序配置端口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文