spring_reference/IX. ‘How-to’ guides/64.2. Change the HTTP port.md

8 lines
895 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

### 64.2. 改变HTTP端口
在一个单独的应用中主HTTP端口默认为8080但可以使用`server.port`设置比如在application.properties中或作为一个系统属性。由于`Environment`值的宽松绑定,你也可以使用`SERVER_PORT`比如作为一个OS环境变
为了完全关闭HTTP端点但仍创建一个WebApplicationContext你可以设置`server.port=-1`(测试时可能有用)。
想获取更多详情可查看'Spring Boot特性'章节的[Section 26.3.3, “Customizing embedded servlet containers”](http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#boot-features-customizing-embedded-containers),或[ServerProperties](http://github.com/spring-projects/spring-boot/tree/master/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java)源码。