spring-boot-starter-web默认的spring-boot-starter-tomcat依赖
org.springframework.boot
spring-boot-starter-web
org.springframework.boot
spring-boot-starter-tomcat
org.springframework.boot
spring-boot-starter-jetty
configurations {
compile.exclude module: "spring-boot-starter-tomcat"
}
dependencies {
compile("org.springframework.boot:spring-boot-starter-web:2.0.0.BUILD-SNAPSHOT")
compile("org.springframework.boot:spring-boot-starter-jetty:2.0.0.BUILD-SNAPSHOT")
}
server:
port: 80
servlet:
context-path: /app
#Jetty specific properties
jetty:
threads:
acceptors: -1 #Number of acceptor threads to use. When the value is -1, the default, the number of acceptors is derived from the operating environment.
selectors: -1 #Number of selector threads to use. When the value is -1, the default, thenumber of selectors is derived from the operating environment.
max-http-form-post-size: 200000 #Maximum size of the form content in any HTTP post request.


RELEASE GA:General Availability,正式发布的版本,官方推荐使用此版本。
SNAPSHOT: 快照版,可以稳定使用,且仍在继续改进版本。
PRE: 预览版,内部测试版. 主要是给开发人员和测试人员测试和找BUG用的,不建议使用。
JettyEmbeddedServletContainerFactory bean来配置这些参数@Bean
public JettyEmbeddedServletContainerFactory jettyEmbeddedServletContainerFactory() {
JettyEmbeddedServletContainerFactory jettyContainer = new JettyEmbeddedServletContainerFactory();
jettyContainer.setPort(80);
jettyContainer.setContextPath("/app");
return jettyContainer;
}
ConfigurableServletWebServerFactory 和 JettyServletWebServerFactory类去配置Jetty参数:@Bean
public ConfigurableServletWebServerFactory configurableServletWebServerFactory(){
//JettyServletWebServerFactory是ConfigurableServletWebServerFactory的实现类
JettyServletWebServerFactory factory = new JettyServletWebServerFactory();
factory.setPort(80);
factory.setContextPath("/app");
factory.setAcceptors(-1);
factory.setSelectors(-1);
factory.addErrorPages(new ErrorPage(HttpStatus.NOT_FOUND, "/404.html"));
return factory;
}