mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-09-03 04:26:12 +08:00
Remove reference to Jersey 1
Closes gh-12582
This commit is contained in:
parent
65738e63fb
commit
699b6ce6dc
@ -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.
|
||||
|
||||
|
||||
|
||||
|
@ -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]
|
||||
|
@ -46,7 +46,6 @@
|
||||
<module>spring-boot-sample-hateoas</module>
|
||||
<module>spring-boot-sample-integration</module>
|
||||
<module>spring-boot-sample-jersey</module>
|
||||
<module>spring-boot-sample-jersey1</module>
|
||||
<module>spring-boot-sample-jetty</module>
|
||||
<module>spring-boot-sample-jetty-jsp</module>
|
||||
<module>spring-boot-sample-jetty-ssl</module>
|
||||
|
@ -1,81 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<!-- Your own application should inherit from spring-boot-starter-parent -->
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-samples</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
<artifactId>spring-boot-sample-jersey1</artifactId>
|
||||
<name>Spring Boot Jersey 1 Sample</name>
|
||||
<description>Spring Boot Jersey 1 Sample</description>
|
||||
<properties>
|
||||
<main.basedir>${basedir}/../..</main.basedir>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<!-- Compile -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-tomcat</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.jersey</groupId>
|
||||
<artifactId>jersey-servlet</artifactId>
|
||||
<version>1.13</version>
|
||||
</dependency>
|
||||
<!-- Test -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<requiresUnpack>
|
||||
<dependency>
|
||||
<groupId>com.sun.jersey</groupId>
|
||||
<artifactId>jersey-servlet</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.jersey</groupId>
|
||||
<artifactId>jersey-server</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.jersey</groupId>
|
||||
<artifactId>jersey-core</artifactId>
|
||||
</dependency>
|
||||
</requiresUnpack>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>java9</id>
|
||||
<activation>
|
||||
<jdk>[9,)</jdk>
|
||||
</activation>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>javax.xml.bind</groupId>
|
||||
<artifactId>jaxb-api</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
@ -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<ServletContainer> jersey() {
|
||||
FilterRegistrationBean<ServletContainer> 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);
|
||||
}
|
||||
|
||||
}
|
@ -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");
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user