JAX-RS客户端Jersey框架所需的jar [英] JAX-RS client Jersey Framework required jars
本文介绍了JAX-RS客户端Jersey框架所需的jar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
运行客户端至少需要泽西框架的最低JAR文件? 如果我将所有JAR都包括在内,则将需要4 MB.
What minimum JAR files of Jersey Framework are needed to run a client? If I include all JAR's it will take 4 MB.
推荐答案
Jersey 2.x(2.22.1)
Jersey 2.x (2.22.1)
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<version>2.22.1</version>
</dependency>
Jersey 1.x(1.19)
Jersey 1.x (1.19)
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<version>1.19</version>
</dependency>
注意:这些只是基本的客户端jar.不支持JSON.
Note: These are just the base client jars. There is no JSON support.
要获得JSON支持,您可以添加这些
For JSON support, you can add these
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
<version>2.6.3</version>
</dependency>
对于Jersey 2,您可以注册JacksonJaxbJsonProvider
For Jersey 2, you can register the JacksonJaxbJsonProvider
Client client = ClientBuilder.newClient();
client.register(JacskonJaxbJsonProvider.class);
对于泽西岛1,您可以
ClientConfig config = new DefaultClientConfig();
config.getClasses().add(JacksonJaxbJsonProvider.class);
Client client = Client.create(config);
另请参见:
- Documentation for 2.x client
- Documentation for 1.x client
这篇关于JAX-RS客户端Jersey框架所需的jar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文