在一个单独的应用中,主HTTP端口默认为8080,不过可以使用server.port设置(比如,在application.properties中或作为系统属性)。由于Environment值的宽松绑定,你也可以使用SERVER_PORT(比如,作为OS环境变量)。
8080
server.port
application.properties
Environment
SERVER_PORT
想要创建WebApplicationContext但完全关闭HTTP端点,你可以设置server.port=-1(测试时可能有用)。具体详情可查看'Spring Boot特性'章节的Section 27.3.4, “Customizing embedded servlet containers”arrow-up-right,或ServerPropertiesarrow-up-right源码。
WebApplicationContext
server.port=-1
Last updated 7 years ago
Was this helpful?