Commit 7bbae21d authored by Brian Clozel's avatar Brian Clozel

Start documenting WebFlux support

This commit adds new reference documentation sections about WebFlux
support in Spring Boot:

* Support for multiple HTTP servers (gh-8403)
* `CodecCustomizer` and JSON codecs (gh-8897, gh-9166)
* `WebClient.Builder` auto-configuration (gh-9522)
* Tests with `@WebFluxTest` (gh-8401)
* `WebTestClient` auto-configuration (gh-8399)
* Support for Thymeleafi and Mustache templating (gh-8124, gh-8648)
* Choose another HTTP server with WebFlux (closes gh-9690)
parent ef5c2afc
......@@ -621,7 +621,7 @@ that any HTTP request with the path "`/`" should be mapped to the `home` method.
back to the caller.
TIP: The `@RestController` and `@RequestMapping` annotations are Spring MVC annotations
(they are not specific to Spring Boot). See the {spring-reference}#mvc[MVC section] in
(they are not specific to Spring Boot). See the {spring-reference}web.html#mvc[MVC section] in
the Spring Reference Documentation for more details.
......
......@@ -487,8 +487,78 @@ Spring Boot. The definitive list comes from searching the source code for
[[howto-embedded-servlet-containers]]
== Embedded servlet containers
[[howto-embedded-web-servers]]
== Embedded Web servers
[[howto-use-another-web-server]]
=== Use another Web server
The Spring Boot starters bring a default embedded container for you:
* `spring-boot-starter-web` brings Tomcat with `spring-boot-starter-tomcat`,
but `spring-boot-starter-jetty` and `spring-boot-starter-undertow` can be used instead.
* `spring-boot-starter-webflux` brings Reactor Netty with `spring-boot-starter-reactor-netty`,
but `spring-boot-starter-tomcat`, `spring-boot-starter-jetty` and
`spring-boot-starter-undertow` can be used instead.
NOTE: Many starters only support Spring MVC, so they transitively bring
`spring-boot-starter-web` into your application classpath
If you choose to use a different HTTP server, you need to exclude those dependencies
and include the one you chose instead. Spring Boot provides separate starters for
HTTP servers to help make this process as easy as possible.
Example in Maven, for Spring MVC:
[source,xml,indent=0,subs="verbatim,quotes,attributes"]
----
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<!-- Exclude the Tomcat dependency -->
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Use Jetty instead -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>
----
Example in Gradle, for Spring WebFlux:
[source,groovy,indent=0,subs="verbatim,quotes,attributes"]
----
configurations {
// exclude Reactor Netty
compile.exclude module: 'spring-boot-starter-reactor-netty'
}
dependencies {
compile 'org.springframework.boot:spring-boot-starter-webflux'
// Use Undertow instead
compile 'org.springframework.boot:spring-boot-starter-undertow'
// ...
}
----
NOTE: `spring-boot-starter-reactor-netty` is required to use the `WebClient`,
so excluding it is not required if you wish to use a different HTTP server.
[[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), but also look at
`ServletWebServerFactoryCustomizer`. The Jetty APIs are quite rich so once you have
access to the `JettyServletWebServerFactory` you can modify it in a number
of ways. Or the nuclear option is to add your own `JettyServletWebServerFactory`.
......@@ -828,104 +898,6 @@ include::{code-examples}/context/embedded/TomcatLegacyCookieProcessorExample.jav
[[howto-use-jetty-instead-of-tomcat]]
=== Use Jetty instead of Tomcat
The Spring Boot starters (`spring-boot-starter-web` in particular) use Tomcat as an
embedded container by default. You need to exclude those dependencies and include the
Jetty one instead. Spring Boot provides Tomcat and Jetty dependencies bundled together
as separate starters to help make this process as easy as possible.
Example in Maven:
[source,xml,indent=0,subs="verbatim,quotes,attributes"]
----
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>
----
Example in Gradle:
[source,groovy,indent=0,subs="verbatim,quotes,attributes"]
----
configurations {
compile.exclude module: 'spring-boot-starter-tomcat'
}
dependencies {
compile 'org.springframework.boot:spring-boot-starter-web'
compile 'org.springframework.boot:spring-boot-starter-jetty'
// ...
}
----
[[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), but also look at
`ServletWebServerFactoryCustomizer`. The Jetty APIs are quite rich so once you have
access to the `JettyServletWebServerFactory` you can modify it in a number
of ways. Or the nuclear option is to add your own `JettyServletWebServerFactory`.
[[howto-use-undertow-instead-of-tomcat]]
=== Use Undertow instead of Tomcat
Using Undertow instead of Tomcat is very similar to <<howto-use-jetty-instead-of-tomcat,
using Jetty instead of Tomcat>>. You need to exclude the Tomcat dependencies and include
the Undertow starter instead.
Example in Maven:
[source,xml,indent=0,subs="verbatim,quotes,attributes"]
----
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-undertow</artifactId>
</dependency>
----
Example in Gradle:
[source,groovy,indent=0,subs="verbatim,quotes,attributes"]
----
configurations {
compile.exclude module: 'spring-boot-starter-tomcat'
}
dependencies {
compile 'org.springframework.boot:spring-boot-starter-web'
compile 'org.springframework.boot:spring-boot-starter-undertow'
// ...
}
----
[[howto-configure-undertow]]
=== Configure Undertow
Generally you can follow the advice from
......@@ -1288,7 +1260,7 @@ Check out {sc-spring-boot-autoconfigure}/web/servlet/WebMvcAutoConfiguration.{sc
[[howto-http-clients-proxy-configuration]]
=== Configure RestTemplate to use a proxy
As described in <<spring-boot-features.adoc#boot-features-restclient-customization>>,
As described in <<spring-boot-features.adoc#boot-features-resttemplate-customization>>,
a `RestTemplateCustomizer` can be used with `RestTemplateBuilder` to build a customized
`RestTemplate`. This is the recommended approach for creating a `RestTemplate` configured
to use a proxy.
......
......@@ -36,7 +36,7 @@ Phillip Webb; Dave Syer; Josh Long; Stéphane Nicoll; Rob Winch; Andy Wilkinson;
:dependency-management-plugin-documentation: {dependency-management-plugin}/blob/master/README.md
:spring-boot-maven-plugin-site: http://docs.spring.io/spring-boot/docs/{spring-boot-docs-version}/maven-plugin/
:spring-boot-gradle-plugin: http://docs.spring.io/spring-boot/docs/{spring-boot-docs-version}/gradle-plugin/
:spring-reference: http://docs.spring.io/spring/docs/{spring-docs-version}/spring-framework-reference/htmlsingle
:spring-reference: http://docs.spring.io/spring/docs/{spring-docs-version}/spring-framework-reference/
:spring-security-reference: http://docs.spring.io/spring-security/site/docs/{spring-security-docs-version}/reference/htmlsingle
:spring-security-oauth2-reference: http://projects.spring.io/spring-security-oauth/docs/oauth2.html
:spring-webservices-reference: http://docs.spring.io/spring-ws/docs/{spring-webservices-docs-version}/reference/htmlsingle
......@@ -52,8 +52,8 @@ Phillip Webb; Dave Syer; Josh Long; Stéphane Nicoll; Rob Winch; Andy Wilkinson;
:ant-manual: http://ant.apache.org/manual
:code-examples: ../java/org/springframework/boot
:gradle-user-guide: https://docs.gradle.org/3.4.1/userguide
:jetty-documentation: https://www.eclipse.org/jetty/documentation/9.3.x
:tomcat-documentation: https://tomcat.apache.org/tomcat-8.0-doc
:jetty-documentation: https://www.eclipse.org/jetty/documentation/9.4.x
:tomcat-documentation: https://tomcat.apache.org/tomcat-8.5-doc
// ======================================================================================
include::documentation-overview.adoc[]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment