类 SpringBootServletInitializer
- java.lang.Object
- org.springframework.boot.web.servlet.support.SpringBootServletInitializer
- 所有已实现的接口:
org.springframework.web.WebApplicationInitializer
public abstract class SpringBootServletInitializer extends Object implements org.springframework.web.WebApplicationInitializer
An opinionatedWebApplicationInitializerto run aSpringApplicationfrom a traditional WAR deployment. BindsServlet,FilterandServletContextInitializerbeans from the application context to the server.To configure the application either override the
configure(SpringApplicationBuilder)method (callingSpringApplicationBuilder.sources(Class...)) or make the initializer itself a@Configuration. If you are usingSpringBootServletInitializerin combination with otherWebApplicationInitializersyou might also want to add an@Orderedannotation to configure a specific startup order.Note that a WebApplicationInitializer is only needed if you are building a war file and deploying it. If you prefer to run an embedded web server then you won't need this at all.
- 从以下版本开始:
- 2.0.0
- 另请参阅:
configure(SpringApplicationBuilder)
字段概要
字段 修饰符和类型 字段 说明 protected org.apache.commons.logging.Loglogger
构造器概要
构造器 构造器 说明 SpringBootServletInitializer()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 protected SpringApplicationBuilderconfigure(SpringApplicationBuilder builder)Configure the application.protected org.springframework.web.context.WebApplicationContextcreateRootApplicationContext(javax.servlet.ServletContext servletContext)protected SpringApplicationBuildercreateSpringApplicationBuilder()Returns theSpringApplicationBuilderthat is used to configure and create theSpringApplication.voidonStartup(javax.servlet.ServletContext servletContext)protected org.springframework.web.context.WebApplicationContextrun(SpringApplication application)Called to run a fully configuredSpringApplication.protected voidsetRegisterErrorPageFilter(boolean registerErrorPageFilter)Set if theErrorPageFiltershould be registered.
字段详细资料
logger
protected org.apache.commons.logging.Log logger
构造器详细资料
SpringBootServletInitializer
public SpringBootServletInitializer()
方法详细资料
setRegisterErrorPageFilter
protected final void setRegisterErrorPageFilter(boolean registerErrorPageFilter)
Set if theErrorPageFiltershould be registered. Set tofalseif error page mappings should be handled via the server and not Spring Boot.- 参数:
registerErrorPageFilter- if theErrorPageFiltershould be registered.
onStartup
public void onStartup(javax.servlet.ServletContext servletContext) throws javax.servlet.ServletException
- 指定者:
onStartup在接口中org.springframework.web.WebApplicationInitializer- 抛出:
javax.servlet.ServletException
createRootApplicationContext
protected org.springframework.web.context.WebApplicationContext createRootApplicationContext(javax.servlet.ServletContext servletContext)
createSpringApplicationBuilder
protected SpringApplicationBuilder createSpringApplicationBuilder()
Returns theSpringApplicationBuilderthat is used to configure and create theSpringApplication. The default implementation returns a newSpringApplicationBuilderin its default state.- 返回:
- the
SpringApplicationBuilder. - 从以下版本开始:
- 1.3.0
run
protected org.springframework.web.context.WebApplicationContext run(SpringApplication application)
Called to run a fully configuredSpringApplication.- 参数:
application- the application to run- 返回:
- the
WebApplicationContext
configure
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder)
Configure the application. Normally all you would need to do is to add sources (e.g. config classes) because other settings have sensible defaults. You might choose (for instance) to add default command line arguments, or set an active Spring profile.- 参数:
builder- a builder for the application context- 返回:
- the application builder
- 另请参阅:
SpringApplicationBuilder