类 SpringBootServletInitializer
java.lang.Object
org.springframework.boot.web.servlet.support.SpringBootServletInitializer
- 所有已实现的接口:
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.
- 从以下版本开始:
- 2.0.0
- 作者:
- Dave Syer, Phillip Webb, Andy Wilkinson, Brian Clozel
- 另请参阅:
-
字段概要
字段 -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明protected SpringApplicationBuilder
configure
(SpringApplicationBuilder builder) Configure the application.protected WebApplicationContext
createRootApplicationContext
(ServletContext servletContext) protected SpringApplicationBuilder
Returns theSpringApplicationBuilder
that is used to configure and create theSpringApplication
.protected void
deregisterJdbcDrivers
(ServletContext servletContext) Deregisters the JDBC drivers that were registered by the application represented by the givenservletContext
.void
onStartup
(ServletContext servletContext) protected WebApplicationContext
run
(SpringApplication application) Called to run a fully configuredSpringApplication
.protected final void
setRegisterErrorPageFilter
(boolean registerErrorPageFilter) Set if theErrorPageFilter
should be registered.protected void
shutDownSharedReactorSchedulers
(ServletContext servletContext) Shuts down the reactorSchedulers
that were initialized bySchedulers.boundedElastic()
(or similar).
-
字段详细资料
-
logger
-
-
构造器详细资料
-
SpringBootServletInitializer
public SpringBootServletInitializer()
-
-
方法详细资料
-
setRegisterErrorPageFilter
protected final void setRegisterErrorPageFilter(boolean registerErrorPageFilter) Set if theErrorPageFilter
should be registered. Set tofalse
if error page mappings should be handled through the server and not Spring Boot.- 参数:
registerErrorPageFilter
- if theErrorPageFilter
should be registered.
-
onStartup
- 指定者:
onStartup
在接口中WebApplicationInitializer
- 抛出:
ServletException
-
deregisterJdbcDrivers
Deregisters the JDBC drivers that were registered by the application represented by the givenservletContext
. The default implementationderegisters
everyDriver
that was loaded by theweb application's class loader
.- 参数:
servletContext
- the web application's servlet context- 从以下版本开始:
- 2.3.0
-
createRootApplicationContext
-
createSpringApplicationBuilder
Returns theSpringApplicationBuilder
that is used to configure and create theSpringApplication
. The default implementation returns a newSpringApplicationBuilder
in its default state.- 返回:
- the
SpringApplicationBuilder
. - 从以下版本开始:
- 1.3.0
-
run
Called to run a fully configuredSpringApplication
.- 参数:
application
- the application to run- 返回:
- the
WebApplicationContext
-
configure
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
- 另请参阅:
-