2016-04-28 2 views
0

2.2.9 Neo4jマニュアルの7.1章のようにJerseyクライアントを使用しようとしています。ここに私のMavenの依存関係の私のコードでMavenを使用してJerseyクライアントをサーブレットコードに統合する方法

 <dependency> 
     <groupId>org.glassfish.jersey.containers</groupId> 
     <!-- if your container implements Servlet API older than 3.0, use "jersey-container-servlet-core" --> 
     <artifactId>jersey-container-servlet</artifactId> 
     <version>2.22.2</version> 
    </dependency> 
    <!-- Required only when you are using JAX-RS Client --> 
    <dependency> 
     <groupId>org.glassfish.jersey.core</groupId> 
     <artifactId>jersey-client</artifactId> 
     <version>2.22.2</version> 
    </dependency> 
    <dependency> 
     <groupId>org.glassfish.jersey.media</groupId> 
     <artifactId>jersey-media-json-jackson</artifactId> 
     <version>2.22.2</version> 
    </dependency> 

があり、私はこのようなインポート:

import org.glassfish.jersey.api.client.*; 

が、私は特定のジャージークラスのクライアントをコンパイルするとき、ClientResponseとリソースが見つかりません。

私はさまざまな依存関係やインポートを試しましたが、何も動作していないようです。

2016年4月現在の正しい方法は何ですか?

おかげ

答えて

0

うん、そう、これらのクラスClientResponseWebResourceジャージー2.xの全く異なるジャージー1.xのクライアントからですあなたは、ガイドと一緒に従う、および1.1を使用したい場合は、単に

<dependency> 
    <groupId>com.sun.jersey</groupId> 
    <artifactId>jersey-json</artifactId> 
    <version>1.19.1</version> 
</dependency> 

あなたはまた、設定する必要がありますJSON/POJOをサポートするために、次の次の依存

<dependency> 
    <groupId>com.sun.jersey</groupId> 
    <artifactId>jersey-client</artifactId> 
    <version>1.19.1</version> 
</dependency> 

を使用し、追加あなたは、新しい2.xのクライアント(あなたが現在持っている依存関係)を使用する場合は、クライアント

ClientConfig config = new DefaultClientConfig(); 
config.getProperties().put(JSONConfiguration.FEATURE_POJO_MAPPING, true); 
Client client = Client.create(config); 

にJSON/POJOのサポートはthe documentationを見てみましょう。また、2.xに行く場合は、jersey-container-servletは必要ありません。これはサーバーの実装のためだけであり、必要のないジャーの束を引っ張ってくるでしょう。

関連する問題