diff --git a/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc b/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc index 43e7292491..2ce7e621df 100644 --- a/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc +++ b/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc @@ -2763,13 +2763,13 @@ does so, the orders shown in the following table will be used: [[boot-features-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] 1.x and -http://cxf.apache.org/[Apache CXF] work quite well out of the box if you register their -`Servlet` or `Filter` as a `@Bean` in your application context. Jersey 2.x has some native -Spring support, so we also provide auto-configuration support for it in Spring Boot, -together with a starter. +available implementations instead of Spring MVC. https://jersey.github.io/[Jersey] and +http://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 2.x, include the `spring-boot-starter-jersey` as a dependency +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: @@ -2828,12 +2828,7 @@ the filter registrations can be given init parameters by using `spring.jersey.in specify a map of properties. There is a {github-code}/spring-boot-samples/spring-boot-sample-jersey[Jersey sample] so -that 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, the spring-boot maven plugin has been configured to -unpack some Jersey jars so that they can be scanned by the JAX-RS implementation (because -the sample asks for them to be scanned in its `Filter` registration). If any of your -JAX-RS resources are packaged as nested jars, you may need to do the same. +that you can see how to set things up. diff --git a/spring-boot-samples/README.adoc b/spring-boot-samples/README.adoc index 3cefc23622..7e71a3c53f 100644 --- a/spring-boot-samples/README.adoc +++ b/spring-boot-samples/README.adoc @@ -84,9 +84,6 @@ The following sample applications are provided: | Integration application built using Spring Integration and its Java DSL | link:spring-boot-sample-jersey[spring-boot-sample-jersey] -| RESTful service built using Jersey 2 - -| link:spring-boot-sample-jersey1[spring-boot-sample-jersey1] | RESTful service built using Jersey | link:spring-boot-sample-jetty[spring-boot-sample-jetty] diff --git a/spring-boot-samples/pom.xml b/spring-boot-samples/pom.xml index 06122d8c5f..cfee119472 100644 --- a/spring-boot-samples/pom.xml +++ b/spring-boot-samples/pom.xml @@ -46,7 +46,6 @@ spring-boot-sample-hateoas spring-boot-sample-integration spring-boot-sample-jersey - spring-boot-sample-jersey1 spring-boot-sample-jetty spring-boot-sample-jetty-jsp spring-boot-sample-jetty-ssl diff --git a/spring-boot-samples/spring-boot-sample-jersey1/pom.xml b/spring-boot-samples/spring-boot-sample-jersey1/pom.xml deleted file mode 100644 index 8df7805ad2..0000000000 --- a/spring-boot-samples/spring-boot-sample-jersey1/pom.xml +++ /dev/null @@ -1,81 +0,0 @@ - - - 4.0.0 - - - org.springframework.boot - spring-boot-samples - ${revision} - - spring-boot-sample-jersey1 - Spring Boot Jersey 1 Sample - Spring Boot Jersey 1 Sample - - ${basedir}/../.. - - - - - org.springframework.boot - spring-boot-starter - - - org.springframework.boot - spring-boot-starter-tomcat - - - org.springframework - spring-web - - - com.sun.jersey - jersey-servlet - 1.13 - - - - org.springframework.boot - spring-boot-starter-test - test - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - com.sun.jersey - jersey-servlet - - - com.sun.jersey - jersey-server - - - com.sun.jersey - jersey-core - - - - - - - - - java9 - - [9,) - - - - javax.xml.bind - jaxb-api - - - - - diff --git a/spring-boot-samples/spring-boot-sample-jersey1/src/main/java/sample/jersey1/SampleJersey1Application.java b/spring-boot-samples/spring-boot-sample-jersey1/src/main/java/sample/jersey1/SampleJersey1Application.java deleted file mode 100644 index 9a7cec432e..0000000000 --- a/spring-boot-samples/spring-boot-sample-jersey1/src/main/java/sample/jersey1/SampleJersey1Application.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2012-2017 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package sample.jersey1; - -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; - -import com.sun.jersey.spi.container.servlet.ServletContainer; - -import org.springframework.boot.WebApplicationType; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.builder.SpringApplicationBuilder; -import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory; -import org.springframework.boot.web.servlet.FilterRegistrationBean; -import org.springframework.context.annotation.Bean; - -@SpringBootApplication -@Path("/") -public class SampleJersey1Application { - - @GET - @Produces("text/plain") - public String hello() { - return "Hello World"; - } - - @Bean - // Not needed if Spring Web MVC is also present on classpath - public TomcatServletWebServerFactory webServerFactory() { - return new TomcatServletWebServerFactory(); - } - - @Bean - public FilterRegistrationBean jersey() { - FilterRegistrationBean bean = new FilterRegistrationBean<>(); - bean.setFilter(new ServletContainer()); - bean.addInitParameter("com.sun.jersey.config.property.packages", - "com.sun.jersey;sample.jersey1"); - return bean; - } - - public static void main(String[] args) { - new SpringApplicationBuilder(SampleJersey1Application.class) - .web(WebApplicationType.SERVLET).run(args); - } - -} diff --git a/spring-boot-samples/spring-boot-sample-jersey1/src/main/resources/application.properties b/spring-boot-samples/spring-boot-sample-jersey1/src/main/resources/application.properties deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/spring-boot-samples/spring-boot-sample-jersey1/src/test/java/sample/jersey1/SampleJersey1ApplicationTests.java b/spring-boot-samples/spring-boot-sample-jersey1/src/test/java/sample/jersey1/SampleJersey1ApplicationTests.java deleted file mode 100644 index 033070fd97..0000000000 --- a/spring-boot-samples/spring-boot-sample-jersey1/src/test/java/sample/jersey1/SampleJersey1ApplicationTests.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2012-2016 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package sample.jersey1; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.test.web.client.TestRestTemplate; -import org.springframework.test.context.junit4.SpringRunner; - -import static org.assertj.core.api.Assertions.assertThat; - -@RunWith(SpringRunner.class) -@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -public class SampleJersey1ApplicationTests { - - @Autowired - private TestRestTemplate restTemplate; - - @Test - public void rootReturnsHelloWorld() { - assertThat(this.restTemplate.getForObject("/", String.class)) - .isEqualTo("Hello World"); - } - -}