如何配置Spring Boot应用程序侦听的TCP/IP端口,使其不使用默认端口8080。


当前回答

您还可以使用SERVER_PORT环境变量来配置Spring Boot端口。只需设置环境变量并重新启动应用程序:

set SERVER_PORT=9999 // on windows machine
export SERVER_PORT=9999 // on linux

请注意,如果你没有在系统范围内设置这些环境变量,你应该在同一个会话上运行引导应用程序。

其他回答

将此添加到应用程序中。属性文件

server.port= 8080

在application.properties中包含下面的属性

server.port=8080

在文件应用程序。属性添加以下内容: server.port = 8888 这里需要经常提到的项目

使用mvn shell命令行,spring-boot 2:

mvn spring-boot:run -Dspring-boot.run.jvmArguments='-Dserver.port=8085'

默认端口号是:8080,但我们可以在application.properties中自定义端口号 如下图所示

spring.mvc.view.prefix=/WEB-INF/jsp/
spring.mvc.view.suffix=.jsp
server.port = 5050 -- #here we can give any port number.