What minimum JAR files of Jersey Framework are needed to run a client? If I include all JAR's it will take 4 MB.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答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)
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<version>1.19</version>
</dependency>
Note: These are just the base client jars. There is no JSON support.
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>
For Jersey 2, you can register the JacksonJaxbJsonProvider
Client client = ClientBuilder.newClient();
client.register(JacskonJaxbJsonProvider.class);
For Jersey 1, you can do
ClientConfig config = new DefaultClientConfig();
config.getClasses().add(JacksonJaxbJsonProvider.class);
Client client = Client.create(config);
See Also:
- Documentation for 2.x client
- Documentation for 1.x client