static WebApplicationType deduceFromClasspath() {
if (ClassUtils.isPresent(WEBFLUX_INDICATOR_CLASS, null) && !ClassUtils.isPresent(WEBMVC_INDICATOR_CLASS, null)
&& !ClassUtils.isPresent(JERSEY_INDICATOR_CLASS, null)) {
return WebApplicationType.REACTIVE;
}
for (String className : SERVLET_INDICATOR_CLASSES) {
if (!ClassUtils.isPresent(className, null)) {
return WebApplicationType.NONE;
}
}
return WebApplicationType.SERVLET;
}
- Spring boot总共有三种web应用类型
- reactive
The application should run as a reactive web application and should start an embedded reactive web server.
* servlet
The application should run as a servlet-based web application and should start an embedded servlet web server.
* none
The application should not run as a web application and should not start an embedded web server.
- Spring boot依据Class path来推断web应用类型
-
reactive
路径包含org.springframework.web.reactive.DispatcherHandler
,并且不包含org.springframework.web.servlet.DispatcherServlet
和org.glassfish.jersey.servlet.ServletContainer
-
none
不是reactive,并且路径中没有javax.servlet.Servlet
和org.springframework.web.context.ConfigurableWebApplicationContext
-
servlet
剩余的部分都是servlet
-
reactive
网友评论