From 4de9a2415d632cff83fc0e681e7e5a9f0d3bee56 Mon Sep 17 00:00:00 2001 From: qibaoguang Date: Wed, 25 Mar 2015 22:33:57 +0800 Subject: [PATCH] Update 64.11. Use Undertow instead of Tomcat.md --- .../64.11. Use Undertow instead of Tomcat.md | 35 ++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/IX. ‘How-to’ guides/64.11. Use Undertow instead of Tomcat.md b/IX. ‘How-to’ guides/64.11. Use Undertow instead of Tomcat.md index f3dc1ee..33bd22e 100644 --- a/IX. ‘How-to’ guides/64.11. Use Undertow instead of Tomcat.md +++ b/IX. ‘How-to’ guides/64.11. Use Undertow instead of Tomcat.md @@ -1,7 +1,34 @@ -### 64.11. 改变HTTP端口 +### 64.11. 使用Undertow替代Tomcat -在一个单独的应用中,主HTTP端口默认为8080,但可以使用`server.port`设置(比如,在application.properties中或作为一个系统属性)。由于`Environment`值的宽松绑定,你也可以使用`SERVER_PORT`(比如,作为一个OS环境变)。 +使用Undertow替代Tomcat和[使用Jetty替代Tomcat](https://github.com/qibaoguang/Spring-Boot-Reference-Guide/edit/master/How-to_%20guides.md)非常类似。你需要排除Tomat依赖,并包含Undertow starter。 -为了完全关闭HTTP端点,但仍创建一个WebApplicationContext,你可以设置`server.port=-1`(测试时可能有用)。 +Maven示例: +```xml + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-tomcat + + + + + org.springframework.boot + spring-boot-starter-undertow + +``` +Gradle示例: +```gradle +configurations { + compile.exclude module: "spring-boot-starter-tomcat" +} -想获取更多详情可查看'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)源码。 +dependencies { + compile 'org.springframework.boot:spring-boot-starter-web:1.3.0.BUILD-SNAPSHOT") + compile 'org.springframework.boot:spring-boot-starter-undertow:1.3.0.BUILD-SNAPSHOT") + // ... +} + +```