public abstract class SpringBootServletInitializer extends Object implements WebApplicationInitializer
WebApplicationInitializer
to run a SpringApplication
from a traditional WAR deployment. Binds Servlet
, Filter
and
ServletContextInitializer
beans from the application context to the servlet
container.
To configure the application either override the
configure(SpringApplicationBuilder)
method (calling
SpringApplicationBuilder.sources(Object...)
) 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 container then you won't need this at all.
configure(SpringApplicationBuilder)
Modifier and Type | Field and Description |
---|---|
protected org.apache.commons.logging.Log |
logger |
Constructor and Description |
---|
SpringBootServletInitializer() |
Modifier and Type | Method and Description |
---|---|
protected SpringApplicationBuilder |
configure(SpringApplicationBuilder builder)
Configure the application.
|
protected WebApplicationContext |
createRootApplicationContext(ServletContext servletContext) |
protected SpringApplicationBuilder |
createSpringApplicationBuilder()
Returns the
SpringApplicationBuilder that is used to configure and create
the SpringApplication . |
void |
onStartup(ServletContext servletContext) |
protected WebApplicationContext |
run(SpringApplication application)
Called to run a fully configured
SpringApplication . |
protected void |
setRegisterErrorPageFilter(boolean registerErrorPageFilter)
Set if the
ErrorPageFilter should be registered. |
protected final void setRegisterErrorPageFilter(boolean registerErrorPageFilter)
ErrorPageFilter
should be registered. Set to false
if
error page mappings should be handled via the Servlet container and not Spring
Boot.registerErrorPageFilter
- if the ErrorPageFilter
should be registered.public void onStartup(ServletContext servletContext) throws ServletException
onStartup
in interface WebApplicationInitializer
ServletException
protected WebApplicationContext createRootApplicationContext(ServletContext servletContext)
protected SpringApplicationBuilder createSpringApplicationBuilder()
SpringApplicationBuilder
that is used to configure and create
the SpringApplication
. The default implementation returns a new
SpringApplicationBuilder
in its default state.SpringApplicationBuilder
.protected WebApplicationContext run(SpringApplication application)
SpringApplication
.application
- the application to runWebApplicationContext
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder)
builder
- a builder for the application contextSpringApplicationBuilder
Copyright © 2016 Pivotal Software, Inc.. All rights reserved.