Jersey 2.x JDK 上的客户端应用

如应用是运行在 JDK 上的话,你只需要使用 JAX-RS 中的客户端部分就可以了,这个根据你使用的客户端有所调整。

这里有一系列的模块是可以供你使用的,例如 grizzly 或 apache 或 jetty connector(请参考下面的的依赖表格)。Jersey 客户端默认使用 JDK 进行运行(使用的是 HttpUrlConnection)。

请参考 Chapter 5, Client API 获得更多的细节。

1
2
3
4
5
<dependency>
    <groupId>org.glassfish.jersey.core</groupId>
    <artifactId>jersey-client</artifactId>
    <version>2.27</version>
</dependency>

当前可用的连接器:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<dependency>
    <groupId>org.glassfish.jersey.connectors</groupId>
    <artifactId>jersey-grizzly-connector</artifactId>
    <version>2.27</version>
</dependency>
 
<dependency>
    <groupId>org.glassfish.jersey.connectors</groupId>
    <artifactId>jersey-apache-connector</artifactId>
    <version>2.27</version>
</dependency>
 
<dependency>
    <groupId>org.glassfish.jersey.connectors</groupId>
    <artifactId>jersey-jetty-connector</artifactId>
    <version>2.27</version>
</dependency>

https://www.cwiki.us/display/JERSEYZH/Common+Jersey+Use+Cases

原文地址:https://www.cnblogs.com/huyuchengus/p/9926160.html