@ -506,15 +506,17 @@ configure the embedded server. This section answers those questions.
@@ -506,15 +506,17 @@ configure the embedded server. This section answers those questions.
[[howto-use-another-web-server]]
=== Use Another Web Server
Many Spring Boot starters include default embedded containers. `spring-boot-starter-web`
includes Tomcat by including `spring-boot-starter-tomcat`, but you can use
`spring-boot-starter-jetty` or `spring-boot-starter-undertow` instead.
`spring-boot-starter-webflux` includes Reactor Netty by including
`spring-boot-starter-reactor-netty`, but you can use `spring-boot-starter-tomcat`,
Many Spring Boot starters include default embedded containers.
* For servlet stack applications, the `spring-boot-starter-web` includes Tomcat by including
`spring-boot-starter-tomcat`, but you can use `spring-boot-starter-jetty` or
`spring-boot-starter-undertow` instead.
* For reactive stack applications, the `spring-boot-starter-webflux` includes Reactor Netty
by including `spring-boot-starter-reactor-netty`, but you can use `spring-boot-starter-tomcat`,
`spring-boot-starter-jetty`, or `spring-boot-starter-undertow` instead.
If you need to use a different HTTP server, you need to exclude the default dependencies
and include the one you need. Spring Boot provides separate starters for
When switching to a different HTTP server, you need to exclude the default dependencies
in addition to including the one you need. Spring Boot provides separate starters for
HTTP servers to help make this process as easy as possible.
The following Maven example shows how to exclude Tomcat and include Jetty for Spring MVC:
@ -576,87 +578,6 @@ your `application.properties`, as shown in the following example:
@@ -576,87 +578,6 @@ your `application.properties`, as shown in the following example:
[[howto-configure-jetty]]
=== Configure Jetty
Generally, you can follow the advice from
"`<<howto-discover-build-in-options-for-external-properties>>`" about
`@ConfigurationProperties` (`ServerProperties` is the main one here). However, you should
==== Add Servlets, Filters, and Listeners by Using Classpath Scanning
`@WebServlet`, `@WebFilter`, and `@WebListener` annotated classes can be automatically
registered with an embedded servlet container by annotating a `@Configuration` class
with `@ServletComponentScan` and specifying the package(s) containing the components
that you want to register. By default, `@ServletComponentScan` scans from the package
of the annotated class.
[[howto-change-the-http-port]]
=== Change the HTTP Port
In a standalone application, the main HTTP port defaults to `8080` but can be set with
@ -720,6 +641,32 @@ processed early (before the value is actually available).
@@ -720,6 +641,32 @@ processed early (before the value is actually available).
[[how-to-enable-http-response-compression]]
=== Enable HTTP Response Compression
HTTP response compression is supported by Jetty, Tomcat, and Undertow. It can be enabled
==== Add Servlets, Filters, and Listeners by Using Classpath Scanning
`@WebServlet`, `@WebFilter`, and `@WebListener` annotated classes can be automatically
registered with an embedded servlet container by annotating a `@Configuration` class
with `@ServletComponentScan` and specifying the package(s) containing the components
that you want to register. By default, `@ServletComponentScan` scans from the package
of the annotated class.
[[howto-configure-accesslogs]]
=== Configure Access Logging
Access logs can be configured for Tomcat, Undertow, and Jetty through their respective
@ -904,19 +988,6 @@ adding a new valve instance in a `TomcatServletWebServerFactory` bean.
@@ -904,19 +988,6 @@ adding a new valve instance in a `TomcatServletWebServerFactory` bean.
[[howto-configure-tomcat]]
=== Configure Tomcat
Generally, you can follow the advice from
"`<<howto-discover-build-in-options-for-external-properties>>`" about
`@ConfigurationProperties` (`ServerProperties` is the main one here). However, you should
also look at `WebServerFactoryCustomizer` and various Tomcat-specific
`+*Customizers+` that you can add. The Tomcat APIs are quite rich. Consequently, once you
have access to the `TomcatServletWebServerFactory`, you can modify it in a number of ways.
Alternatively, if you need more control and customization, you can add your own
`TomcatServletWebServerFactory`.
[[howto-enable-multiple-connectors-in-tomcat]]
=== Enable Multiple Connectors with Tomcat
You can add an `org.apache.catalina.connector.Connector` to the
"`<<howto-discover-build-in-options-for-external-properties>>`" about
`@ConfigurationProperties` (`ServerProperties` and `ServerProperties.Undertow` are the
main ones here). However, you should also look at `WebServerFactoryCustomizer`.
Once you have access to the `UndertowServletWebServerFactory`, you can use an
`UndertowBuilderCustomizer` to modify Undertow's configuration to meet your needs.
Alternatively, if you need more control and customization, you can add your own
`UndertowServletWebServerFactory`.
[[howto-enable-multiple-listeners-in-undertow]]
=== Enable Multiple Listeners with Undertow
Add an `UndertowBuilderCustomizer` to the `UndertowServletWebServerFactory` and
@ -1040,32 +1098,6 @@ this role is performed by a servlet container initializer, and the
@@ -1040,32 +1098,6 @@ this role is performed by a servlet container initializer, and the
[[how-to-enable-http-response-compression]]
=== Enable HTTP Response Compression
HTTP response compression is supported by Jetty, Tomcat, and Undertow. It can be enabled