Class SpringBootServletInitializer
java.lang.Object
org.springframework.boot.web.servlet.support.SpringBootServletInitializer
- All Implemented Interfaces:
- WebApplicationInitializer
public abstract class SpringBootServletInitializer
extends Object
implements WebApplicationInitializer
An opinionated 
WebApplicationInitializer to run a SpringApplication
from a traditional WAR deployment. Binds Servlet, Filter and
ServletContextInitializer beans from the application context to the server.
To configure the application either override the
configure(SpringApplicationBuilder) method (calling
SpringApplicationBuilder.sources(Class...)) or make the initializer itself a
@Configuration. If you are using SpringBootServletInitializer in
combination with other WebApplicationInitializers you
might also want to add an @Ordered annotation 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.
- Since:
- 2.0.0
- Author:
- Dave Syer, Phillip Webb, Andy Wilkinson, Brian Clozel
- See Also:
- 
Field SummaryFields
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected SpringApplicationBuilderconfigure(SpringApplicationBuilder builder) Configure the application.protected @Nullable WebApplicationContextcreateRootApplicationContext(ServletContext servletContext) protected SpringApplicationBuilderReturns theSpringApplicationBuilderthat is used to configure and create theSpringApplication.protected voidderegisterJdbcDrivers(ServletContext servletContext) Deregisters the JDBC drivers that were registered by the application represented by the givenservletContext.voidonStartup(ServletContext servletContext) protected @Nullable WebApplicationContextrun(SpringApplication application) Called to run a fully configuredSpringApplication.protected final voidsetRegisterErrorPageFilter(boolean registerErrorPageFilter) Set if theErrorPageFiltershould be registered.protected voidshutDownSharedReactorSchedulers(ServletContext servletContext) Shuts down the reactorSchedulersthat were initialized bySchedulers.boundedElastic()(or similar).
- 
Field Details- 
loggerprotected @Nullable org.apache.commons.logging.Log logger
 
- 
- 
Constructor Details- 
SpringBootServletInitializerpublic SpringBootServletInitializer()
 
- 
- 
Method Details- 
setRegisterErrorPageFilterprotected final void setRegisterErrorPageFilter(boolean registerErrorPageFilter) Set if theErrorPageFiltershould be registered. Set tofalseif error page mappings should be handled through the server and not Spring Boot.- Parameters:
- registerErrorPageFilter- if the- ErrorPageFiltershould be registered.
 
- 
onStartup- Specified by:
- onStartupin interface- WebApplicationInitializer
- Throws:
- ServletException
 
- 
deregisterJdbcDriversDeregisters the JDBC drivers that were registered by the application represented by the givenservletContext. The default implementationderegisterseveryDriverthat was loaded by theweb application's class loader.- Parameters:
- servletContext- the web application's servlet context
- Since:
- 2.3.0
 
- 
createRootApplicationContextprotected @Nullable WebApplicationContext createRootApplicationContext(ServletContext servletContext) 
- 
createSpringApplicationBuilderReturns theSpringApplicationBuilderthat is used to configure and create theSpringApplication. The default implementation returns a newSpringApplicationBuilderin its default state.- Returns:
- the SpringApplicationBuilder.
 
- 
runCalled to run a fully configuredSpringApplication.- Parameters:
- application- the application to run
- Returns:
- the WebApplicationContext
 
- 
configureConfigure 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.- Parameters:
- builder- a builder for the application context
- Returns:
- the application builder
- See Also:
 
 
-