Add support for spring.jersey.type=filter

Fixes gh-1756
This commit is contained in:
Dave Syer
2014-11-19 16:51:55 +00:00
parent 3a4f1f6f39
commit 7fa0ea7c3b
7 changed files with 381 additions and 25 deletions

View File

@@ -1083,11 +1083,22 @@ can `@Autowired` dependencies and inject external configuration with `@Value`. T
servlet will be registered and mapped to '`+/*+`' by default. You can change the mapping
by adding `@ApplicationPath` to your `ResourceConfig`.
By default Jersey will be set up as a Servlet in a `@Bean` of type
`ServletRegistrationBean` named "jerseyServletRegistration". 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 servlet has an `@Order`
which you can set with `spring.jersey.filter.order`. Both the Servlet
and the Filter registrations can be given init parameters using
`spring.jersey.init.*` to specify a map of properties.
There is a {github-code}/spring-boot-samples/spring-boot-sample-jersey[Jersey sample] so
you can see how to set things up. There is also a {github-code}/spring-boot-samples/spring-boot-sample-jersey1[Jersey 1.x sample].
Note that in the Jersey 1.x sample that the spring-boot maven plugin has been configured to
unpack some Jersey jars so they can be scanned by the JAX-RS implementation (the sample
asks for them to be scanned in its `Filter` registration).
unpack some Jersey jars so they can be scanned by the JAX-RS implementation (because the sample
asks for them to be scanned in its `Filter` registration). You may need to do the same
if any of your JAX-RS resources are packages as nested jars.