[英]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
版本,但是:
org.glassfish.jersey.core
而不是com.sun.jersey
; 和jersey-apache-client4
) 似乎不存在於 2.x 領域所以我問,我所有的2.21
依賴項應該是什么? 這些天,那個 Jersey/Apache 客戶端藏在哪里?
對於澤西島客戶,您只需要
compile 'org.glassfish.jersey.core:jersey-client:2.21'
jersey-core
不再存在,盡管它可以被認為類似於jersey-common
。 但是你不必擔心這個。 jersey-client
把它拉進來。
至於 Apache,Jersey 2 使用連接器提供程序。 請參閱客戶端傳輸連接器。 你想要的是 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 的一般用法,請參閱第 5 章。客戶端 API
您的問題標題非常籠統,但從您的依賴項來看,您只是在嘗試實現客戶端。 但是對於想要實現服務器的任何其他人,他們可以查看
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.