Drop support for Jersey until jersey-spring6 is available
Closes gh-28808
This commit is contained in:
@@ -90,7 +90,7 @@ The following technology-agnostic endpoints are available:
|
||||
| Performs a thread dump.
|
||||
|===
|
||||
|
||||
If your application is a web application (Spring MVC, Spring WebFlux, or Jersey), you can use the following additional endpoints:
|
||||
If your application is a web application (Spring MVC or Spring WebFlux), you can use the following additional endpoints:
|
||||
|
||||
[cols="2,5"]
|
||||
|===
|
||||
@@ -438,8 +438,7 @@ TIP: See {spring-boot-actuator-autoconfigure-module-code}/endpoint/web/CorsEndpo
|
||||
[[actuator.endpoints.implementing-custom]]
|
||||
=== Implementing Custom Endpoints
|
||||
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.
|
||||
Endpoints can be exposed over HTTP by using Jersey, Spring MVC, or Spring WebFlux.
|
||||
If both Jersey and Spring MVC are available, Spring MVC is used.
|
||||
Endpoints can be exposed over HTTP by using Spring MVC, or Spring WebFlux.
|
||||
|
||||
The following example exposes a read operation that returns a custom object:
|
||||
|
||||
@@ -502,8 +501,7 @@ Before calling an operation method, the input received over JMX or HTTP is conve
|
||||
|
||||
[[actuator.endpoints.implementing-custom.web]]
|
||||
==== Custom Web Endpoints
|
||||
Operations on an `@Endpoint`, `@WebEndpoint`, or `@EndpointWebExtension` are automatically exposed over HTTP using Jersey, Spring MVC, or Spring WebFlux.
|
||||
If both Jersey and Spring MVC are available, Spring MVC is used.
|
||||
Operations on an `@Endpoint`, `@WebEndpoint`, or `@EndpointWebExtension` are automatically exposed over HTTP using Spring MVC or Spring WebFlux.
|
||||
|
||||
|
||||
|
||||
@@ -582,9 +580,7 @@ If an operation is invoked without a required parameter or with a parameter that
|
||||
[[actuator.endpoints.implementing-custom.web.range-requests]]
|
||||
===== Web Endpoint Range Requests
|
||||
You can use an HTTP range request to request part of an HTTP resource.
|
||||
When using Spring MVC or Spring Web Flux, operations that return a `org.springframework.core.io.Resource` automatically support range requests.
|
||||
|
||||
NOTE: Range requests are not supported when using Jersey.
|
||||
Operations that return a `org.springframework.core.io.Resource` automatically support range requests.
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -767,41 +767,6 @@ Applications can opt in and record exceptions by <<web#web.reactive.webflux.erro
|
||||
|
||||
|
||||
|
||||
[[actuator.metrics.supported.jersey]]
|
||||
==== Jersey Server Metrics
|
||||
Auto-configuration enables the instrumentation of all requests handled by the Jersey JAX-RS implementation.
|
||||
By default, metrics are generated with the name, `http.server.requests`.
|
||||
You can customize the name by setting the configprop:management.metrics.web.server.request.metric-name[] property.
|
||||
|
||||
`@Timed` annotations are supported on request-handling classes and methods (see <<actuator#actuator.metrics.supported.timed-annotation>> for details).
|
||||
If you do not want to record metrics for all Jersey requests, you can set configprop:management.metrics.web.server.request.autotime.enabled[] to `false` and exclusively use `@Timed` annotations instead.
|
||||
|
||||
By default, Jersey server metrics are tagged with the following information:
|
||||
|
||||
|===
|
||||
| Tag | Description
|
||||
|
||||
| `exception`
|
||||
| The simple class name of any exception that was thrown while handling the request.
|
||||
|
||||
| `method`
|
||||
| The request's method (for example, `GET` or `POST`)
|
||||
|
||||
| `outcome`
|
||||
| The request's outcome, based on the status code of the response.
|
||||
1xx is `INFORMATIONAL`, 2xx is `SUCCESS`, 3xx is `REDIRECTION`, 4xx is `CLIENT_ERROR`, and 5xx is `SERVER_ERROR`
|
||||
|
||||
| `status`
|
||||
| The response's HTTP status code (for example, `200` or `500`)
|
||||
|
||||
| `uri`
|
||||
| The request's URI template prior to variable substitution, if possible (for example, `/api/person/\{id}`)
|
||||
|===
|
||||
|
||||
To customize the tags, provide a `@Bean` that implements `JerseyTagsProvider`.
|
||||
|
||||
|
||||
|
||||
[[actuator.metrics.supported.http-clients]]
|
||||
==== HTTP Client Metrics
|
||||
Spring Boot Actuator manages the instrumentation of both `RestTemplate` and `WebClient`.
|
||||
|
||||
@@ -4,8 +4,7 @@ If you are developing a web application, Spring Boot Actuator auto-configures al
|
||||
The default convention is to use the `id` of the endpoint with a prefix of `/actuator` as the URL path.
|
||||
For example, `health` is exposed as `/actuator/health`.
|
||||
|
||||
TIP: Actuator is supported natively with Spring MVC, Spring WebFlux, and Jersey.
|
||||
If both Jersey and Spring MVC are available, Spring MVC is used.
|
||||
TIP: Actuator is supported natively with Spring MVC and Spring WebFlux.
|
||||
|
||||
NOTE: Jackson is a required dependency in order to get the correct JSON responses as documented in the API documentation ({spring-boot-actuator-restapi-docs}[HTML] or {spring-boot-actuator-restapi-pdfdocs}[PDF]).
|
||||
|
||||
|
||||
@@ -186,7 +186,6 @@ boot-features-webflux-template-engines=features.developing-web-applications.spri
|
||||
boot-features-webflux-error-handling=features.developing-web-applications.spring-webflux.error-handling
|
||||
boot-features-webflux-error-handling-custom-error-pages=features.developing-web-applications.spring-webflux.error-handling.error-pages
|
||||
boot-features-webflux-web-filters=features.developing-web-applications.spring-webflux.web-filters
|
||||
boot-features-jersey=features.developing-web-applications.jersey
|
||||
boot-features-embedded-container=features.developing-web-applications.embedded-container
|
||||
boot-features-embedded-container-servlets-filters-listeners=features.developing-web-applications.embedded-container.servlets-filters-listeners
|
||||
boot-features-embedded-container-servlets-filters-listeners-beans=features.developing-web-applications.embedded-container.servlets-filters-listeners.beans
|
||||
@@ -475,7 +474,6 @@ production-ready-metrics-system=actuator.metrics.supported.system
|
||||
production-ready-metrics-logger=actuator.metrics.supported.logger
|
||||
production-ready-metrics-spring-mvc=actuator.metrics.supported.spring-mvc
|
||||
production-ready-metrics-web-flux=actuator.metrics.supported.spring-webflux
|
||||
production-ready-metrics-jersey-server=actuator.metrics.supported.jersey
|
||||
production-ready-metrics-http-clients=actuator.metrics.supported.http-clients
|
||||
production-ready-metrics-tomcat=actuator.metrics.supported.tomcat
|
||||
production-ready-metrics-cache=actuator.metrics.supported.cache
|
||||
@@ -619,9 +617,6 @@ howto-switch-off-the-spring-mvc-dispatcherservlet=howto.spring-mvc.switch-off-di
|
||||
howto-switch-off-default-mvc-configuration=howto.spring-mvc.switch-off-default-configuration
|
||||
howto-customize-view-resolvers=howto.spring-mvc.customize-view-resolvers
|
||||
howto-use-test-with-spring-security=howto.spring-mvc.testing.with-spring-security
|
||||
howto-jersey=howto.jersey
|
||||
howto-jersey-spring-security=howto.jersey.spring-security
|
||||
howto-jersey-alongside-another-web-framework=howto.jersey.alongside-another-web-framework
|
||||
howto-http-clients=howto.http-clients
|
||||
howto-http-clients-proxy-configuration=howto.http-clients.rest-template-proxy-configuration
|
||||
howto-webclient-reactor-netty-customization=howto.http-clients.webclient-reactor-netty-customization
|
||||
@@ -848,7 +843,6 @@ features.developing-web-applications.spring-mvc.error-handling.error-pages=web.s
|
||||
features.developing-web-applications.spring-mvc.error-handling.error-pages-without-spring-mvc=web.servlet.spring-mvc.error-handling.error-pages-without-spring-mvc
|
||||
features.developing-web-applications.spring-mvc.error-handling.in-a-war-deployment=web.servlet.spring-mvc.error-handling.in-a-war-deployment
|
||||
features.developing-web-applications.spring-mvc.cors=web.servlet.spring-mvc.cors
|
||||
features.developing-web-applications.jersey=web.servlet.jersey
|
||||
features.developing-web-applications.embedded-container=web.servlet.embedded-container
|
||||
features.developing-web-applications.embedded-container.servlets-filters-listeners=web.servlet.embedded-container.servlets-filters-listeners
|
||||
features.developing-web-applications.embedded-container.servlets-filters-listeners.beans=web.servlet.embedded-container.servlets-filters-listeners.beans
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
== Web
|
||||
If you develop Spring Boot web applications, take a look at the following content:
|
||||
|
||||
* *Servlet Web Applications:* <<web#web.servlet, Spring MVC, Jersey, Embedded Servlet Containers>>
|
||||
* *Servlet Web Applications:* <<web#web.servlet, Spring MVC, Embedded Servlet Containers>>
|
||||
* *Reactive Web Applications:* <<web#web.reactive, Spring Webflux, Embedded Servlet Containers>>
|
||||
* *Graceful Shutdown:* <<web#web.graceful-shutdown, Graceful Shutdown>>
|
||||
* *Spring Security:* <<web#web.security, Default Security Configuration, Auto-configuration for OAuth2, SAML>>
|
||||
|
||||
@@ -23,8 +23,6 @@ include::howto/webserver.adoc[]
|
||||
|
||||
include::howto/spring-mvc.adoc[]
|
||||
|
||||
include::howto/jersey.adoc[]
|
||||
|
||||
include::howto/http-clients.adoc[]
|
||||
|
||||
include::howto/logging.adoc[]
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
[[howto.jersey]]
|
||||
== Jersey
|
||||
|
||||
|
||||
|
||||
[[howto.jersey.spring-security]]
|
||||
=== Secure Jersey endpoints with Spring Security
|
||||
Spring Security can be used to secure a Jersey-based web application in much the same way as it can be used to secure a Spring MVC-based web application.
|
||||
However, if you want to use Spring Security's method-level security with Jersey, you must configure Jersey to use `setStatus(int)` rather `sendError(int)`.
|
||||
This prevents Jersey from committing the response before Spring Security has had an opportunity to report an authentication or authorization failure to the client.
|
||||
|
||||
The `jersey.config.server.response.setStatusOverSendError` property must be set to `true` on the application's `ResourceConfig` bean, as shown in the following example:
|
||||
|
||||
[source,java,indent=0,subs="verbatim"]
|
||||
----
|
||||
include::{docs-java}/howto/jersey/springsecurity/JerseySetStatusOverSendErrorConfig.java[]
|
||||
----
|
||||
|
||||
|
||||
|
||||
[[howto.jersey.alongside-another-web-framework]]
|
||||
=== Use Jersey Alongside Another Web Framework
|
||||
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.
|
||||
First, configure Jersey to use a filter rather than a servlet by configuring the configprop:spring.jersey.type[] application property with a value of `filter`.
|
||||
Second, configure your `ResourceConfig` to forward requests that would have resulted in a 404, as shown in the following example.
|
||||
|
||||
[source,java,indent=0,subs="verbatim"]
|
||||
----
|
||||
include::{docs-java}/howto/jersey/alongsideanotherwebframework/JerseyConfig.java[]
|
||||
----
|
||||
@@ -1,6 +1,6 @@
|
||||
[[web.servlet]]
|
||||
== Servlet Web Applications
|
||||
If you want to build servlet-based web applications, you can take advantage of Spring Boot's auto-configuration for Spring MVC or Jersey.
|
||||
If you want to build servlet-based web applications, you can take advantage of Spring Boot's auto-configuration for Spring MVC.
|
||||
|
||||
[[web.servlet.spring-mvc]]
|
||||
=== The "`Spring Web MVC Framework`"
|
||||
@@ -456,48 +456,6 @@ include::{docs-java}/web/servlet/springmvc/cors/MyCorsConfiguration.java[]
|
||||
|
||||
|
||||
|
||||
[[web.servlet.jersey]]
|
||||
=== JAX-RS and Jersey
|
||||
If you prefer the JAX-RS programming model for REST endpoints, you can use one of the available implementations instead of Spring MVC.
|
||||
https://jersey.github.io/[Jersey] and https://cxf.apache.org/[Apache CXF] work quite well out of the box.
|
||||
CXF requires you to register its `Servlet` or `Filter` as a `@Bean` in your application context.
|
||||
Jersey has some native Spring support, so we also provide auto-configuration support for it in Spring Boot, together with a starter.
|
||||
|
||||
To get started with Jersey, include the `spring-boot-starter-jersey` as a dependency and then you need one `@Bean` of type `ResourceConfig` in which you register all the endpoints, as shown in the following example:
|
||||
|
||||
[source,java,indent=0,subs="verbatim"]
|
||||
----
|
||||
include::{docs-java}/web/servlet/jersey/MyJerseyConfig.java[]
|
||||
----
|
||||
|
||||
WARNING: Jersey's support for scanning executable archives is rather limited.
|
||||
For example, it cannot scan for endpoints in a package found in a <<deployment#deployment.installing, fully executable jar file>> or in `WEB-INF/classes` when running an executable war file.
|
||||
To avoid this limitation, the `packages` method should not be used, and endpoints should be registered individually by using the `register` method, as shown in the preceding example.
|
||||
|
||||
For more advanced customizations, you can also register an arbitrary number of beans that implement `ResourceConfigCustomizer`.
|
||||
|
||||
All the registered endpoints should be `@Components` with HTTP resource annotations (`@GET` and others), as shown in the following example:
|
||||
|
||||
[source,java,indent=0,subs="verbatim"]
|
||||
----
|
||||
include::{docs-java}/web/servlet/jersey/MyEndpoint.java[]
|
||||
----
|
||||
|
||||
Since the `Endpoint` is a Spring `@Component`, its lifecycle is managed by Spring and you can use the `@Autowired` annotation to inject dependencies and use the `@Value` annotation to inject external configuration.
|
||||
By default, the Jersey servlet is registered and mapped to `/*`.
|
||||
You can change the mapping by adding `@ApplicationPath` to your `ResourceConfig`.
|
||||
|
||||
By default, Jersey is set up as a servlet in a `@Bean` of type `ServletRegistrationBean` named `jerseyServletRegistration`.
|
||||
By default, the servlet is initialized lazily, but you can customize that behavior by setting `spring.jersey.servlet.load-on-startup`.
|
||||
You can disable or override that bean by creating one of your own with the same name.
|
||||
You can also use a filter instead of a servlet by setting `spring.jersey.type=filter` (in which case, the `@Bean` to replace or override is `jerseyFilterRegistration`).
|
||||
The filter has an `@Order`, which you can set with `spring.jersey.filter.order`.
|
||||
When using Jersey as a filter, a servlet that will handle any requests that are not intercepted by Jersey must be present.
|
||||
If your application does not contain such a servlet, you may want to enable the default servlet by setting configprop:server.servlet.register-default-servlet[] to `true`.
|
||||
Both the servlet and the filter registrations can be given init parameters by using `spring.jersey.init.*` to specify a map of properties.
|
||||
|
||||
|
||||
|
||||
[[web.servlet.embedded-container]]
|
||||
=== Embedded Servlet Container Support
|
||||
For servlet application, Spring Boot includes support for embedded https://tomcat.apache.org/[Tomcat], https://www.eclipse.org/jetty/[Jetty], and https://github.com/undertow-io/undertow[Undertow] servers.
|
||||
|
||||
Reference in New Issue
Block a user