Skip to content

Commit 8b62f44

Browse files
committedNov 5, 2019
Improve documentation on using Jersey alongside Spring MVC
Previously, the documentation did not provide any guidance on using Jersey alongside Spring MVC or any other web framework. This improves the documentation in two ways: 1. It notes that, in the presence of both Jersey and Spring MVC, the Actuator will prefer Spring MVC for exposing HTTP endpoints. 2. It adds a how-to describing how to configure Jersey to forward requests for which it has no handler on to the rest of the filter chain. When Spring MVC is the other framework, this allows them to be handled by its dispatcher servlet. Closes spring-projectsgh-17523
1 parent bd06a91 commit 8b62f44

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed
 

‎spring-boot-project/spring-boot-docs/src/main/asciidoc/howto.adoc

+21
Original file line numberDiff line numberDiff line change
@@ -1219,6 +1219,27 @@ include::{code-examples}/jersey/JerseySetStatusOverSendErrorExample.java[tag=res
12191219

12201220

12211221

1222+
[[howto-jersey-alongside-another-web-framework]]
1223+
=== Use Jersey Alongside Another Web Framework
1224+
To use Jersey alongside another web framework, such as Spring MVC, it should be configured so that it will allow the other framework to handle requests that it cannot handle.
1225+
First, configure Jersey to use a Filter rather than a Servlet by configuring the `spring.jersey.type` application property with a value of `filter`.
1226+
Second, configure your `ResourceConfig` to forward requests that would have resulted in a 404, as shown in the following example.
1227+
1228+
[source,java,indent=0,subs="verbatim,quotes,attributes"]
1229+
----
1230+
@Component
1231+
public class JerseyConfig extends ResourceConfig {
1232+
1233+
public JerseyConfig() {
1234+
register(Endpoint.class);
1235+
property(ServletProperties.FILTER_FORWARD_ON_404, true);
1236+
}
1237+
1238+
}
1239+
----
1240+
1241+
1242+
12221243
[[howto-http-clients]]
12231244
== HTTP Clients
12241245
Spring Boot offers a number of starters that work with HTTP clients.

‎spring-boot-project/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc

+3
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,7 @@ TIP: See {spring-boot-actuator-autoconfigure-module-code}/endpoint/web/CorsEndpo
461461
=== Implementing Custom Endpoints
462462
If you add a `@Bean` annotated with `@Endpoint`, any methods annotated with `@ReadOperation`, `@WriteOperation`, or `@DeleteOperation` are automatically exposed over JMX and, in a web application, over HTTP as well.
463463
Endpoints can be exposed over HTTP using Jersey, Spring MVC, or Spring WebFlux.
464+
If both Jersey and Spring MVC are available, Spring MVC will be used.
464465

465466
You can also write technology-specific endpoints by using `@JmxEndpoint` or `@WebEndpoint`.
466467
These endpoints are restricted to their respective technologies.
@@ -512,6 +513,7 @@ Before calling an operation method, the input received via JMX or an HTTP reques
512513
[[production-ready-endpoints-custom-web]]
513514
==== Custom Web Endpoints
514515
Operations on an `@Endpoint`, `@WebEndpoint`, or `@EndpointWebExtension` are automatically exposed over HTTP using Jersey, Spring MVC, or Spring WebFlux.
516+
If both Jersey and Spring MVC are available, Spring MVC will be used.
515517

516518

517519

@@ -968,6 +970,7 @@ The default convention is to use the `id` of the endpoint with a prefix of `/act
968970
For example, `health` is exposed as `/actuator/health`.
969971

970972
TIP: Actuator is supported natively with Spring MVC, Spring WebFlux, and Jersey.
973+
If both Jersey and Spring MVC are available, Spring MVC will be used.
971974

972975

973976

0 commit comments

Comments
 (0)
Please sign in to comment.