正在从 Jersey 1.x 升级到 2.x
Upgrading from Jersey 1.x to 2.x
请注意:也有类似的问题,但没有什么可以使它成为确切的骗局。
我目前有以下 Gradle 依赖项:
dependencies {
compile "com.sun.jersey.contribs:jersey-apache-client4:1.18.1"
compile "com.sun.jersey:jersey-client:1.18.1"
compile "com.sun.jersey:jersey-core:1.18.1"
compile "com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:2.3.2"
compile "org.apache.httpcomponents:httpclient:4.3.2"
compile "org.slf4j:jcl-over-slf4j:1.7.7"
}
我想将它们升级到 Jersey 的 2.21
版本,但是:
- 似乎groupName现在是
org.glassfish.jersey.core
而不是com.sun.jersey
;和
- 似乎 Jersey-Client 现在不需要显式声明 Jersey-Core(Jersey-Core 似乎不再作为 JAR 存在)
- Jersey Apache 4 客户端 (
jersey-apache-client4
) 似乎不存在于 2.x 土地
所以我问,我所有的 2.21
依赖项应该是什么?这些天 Jersey/Apache 客户躲在哪里?
对于 Jersey 客户端,您只需要
compile 'org.glassfish.jersey.core:jersey-client:2.21'
jersey-core
不再存在,尽管它可以被认为类似于 jersey-common
。但你不必为此担心。 jersey-client
拉进来。
至于 Apache,Jersey 2 使用连接器提供程序。参见 Client Transport Connectors。你想要的是 Apache 连接器
compile 'org.glassfish.jersey.connectors:jersey-apache-connector:2.21'
然后只需配置 Client
ClientConfig config = new ClientConfig();
config.connectorProvider(new ApacheConnectorProvider());
config.register(JacksonJsonProvider.class);
Client client = ClientBuilder.newClient(config);
您还应该摆脱当前的 httpclient
依赖。 jersey-apache-connector
拉进来。
有关新客户端 API 的一般用法,请参阅 Chapter 5. Client API
你的问题标题很笼统,但从你的依赖关系来看,你只是在尝试实现客户端。但是对于任何其他想要实现服务器的人,他们可以查看
请注意:也有类似的问题,但没有什么可以使它成为确切的骗局。
我目前有以下 Gradle 依赖项:
dependencies {
compile "com.sun.jersey.contribs:jersey-apache-client4:1.18.1"
compile "com.sun.jersey:jersey-client:1.18.1"
compile "com.sun.jersey:jersey-core:1.18.1"
compile "com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:2.3.2"
compile "org.apache.httpcomponents:httpclient:4.3.2"
compile "org.slf4j:jcl-over-slf4j:1.7.7"
}
我想将它们升级到 Jersey 的 2.21
版本,但是:
- 似乎groupName现在是
org.glassfish.jersey.core
而不是com.sun.jersey
;和 - 似乎 Jersey-Client 现在不需要显式声明 Jersey-Core(Jersey-Core 似乎不再作为 JAR 存在)
- Jersey Apache 4 客户端 (
jersey-apache-client4
) 似乎不存在于 2.x 土地
所以我问,我所有的 2.21
依赖项应该是什么?这些天 Jersey/Apache 客户躲在哪里?
对于 Jersey 客户端,您只需要
compile 'org.glassfish.jersey.core:jersey-client:2.21'
jersey-core
不再存在,尽管它可以被认为类似于 jersey-common
。但你不必为此担心。 jersey-client
拉进来。
至于 Apache,Jersey 2 使用连接器提供程序。参见 Client Transport Connectors。你想要的是 Apache 连接器
compile 'org.glassfish.jersey.connectors:jersey-apache-connector:2.21'
然后只需配置 Client
ClientConfig config = new ClientConfig();
config.connectorProvider(new ApacheConnectorProvider());
config.register(JacksonJsonProvider.class);
Client client = ClientBuilder.newClient(config);
您还应该摆脱当前的 httpclient
依赖。 jersey-apache-connector
拉进来。
有关新客户端 API 的一般用法,请参阅 Chapter 5. Client API
你的问题标题很笼统,但从你的依赖关系来看,你只是在尝试实现客户端。但是对于任何其他想要实现服务器的人,他们可以查看