Jersey入门到放弃-3

1. Jersey与JDK的兼容性

Jersey versionJDK version
2.6-6.0
2.6+7.0(core-common and core-client支持6.0)

2.Jersey不同类型项目所需的Jersey依赖

  • 基于GlassFish 服务器的Jersey项目,添加如下API就行:
    <dependency>
        <groupId>javax.ws.rs</groupId>
        <artifactId>javax.ws.rs-api</artifactId>
        <version>2.0.1</version>
        <scope>provided</scope>
    </dependency>

    但是如果你还想继续使用jersey的特性,那就直接引入如下配置:

    <dependency>
        <groupId>org.glassfish.jersey.containers</groupId>
        <artifactId>jersey-container-servlet</artifactId>
        <version>2.25.1</version>
        <scope>provided</scope>
    </dependency>
    <!-- if you are using Jersey client specific features without the server side -->
    <dependency>
        <groupId>org.glassfish.jersey.core</groupId>
        <artifactId>jersey-client</artifactId>
        <version>2.25.1</version>
        <scope>provided</scope>
    </dependency>
  • 基于Servlet容器的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.25.1</version>
    </dependency>
    <!-- Required only when you are using JAX-RS Client -->
    <dependency>
        <groupId>org.glassfish.jersey.core</groupId>
        <artifactId>jersey-client</artifactId>
        <version>2.25.1</version>
    </dependency>

     

  • 基于Jersey客户端项目 引入如下配置:
<dependency>
    <groupId>org.glassfish.jersey.core</groupId>
    <artifactId>jersey-client</artifactId>
    <version>2.25.1</version>
</dependency>

        针对要访问的服务器,可以再引入相应的connector:

<dependency>
    <groupId>org.glassfish.jersey.connectors</groupId>
    <artifactId>jersey-grizzly-connector</artifactId>
    <version>2.25.1</version>
</dependency>
 
<dependency>
    <groupId>org.glassfish.jersey.connectors</groupId>
    <artifactId>jersey-apache-connector</artifactId>
    <version>2.25.1</version>
</dependency>
 
<dependency>
    <groupId>org.glassfish.jersey.connectors</groupId>
    <artifactId>jersey-jetty-connector</artifactId>
    <version>2.25.1</version>
</dependency>

     Jersey也支持多种通过编程方式部署Restful api。

      第一篇文章https://my.oschina.net/javastorm/blog/876728 就是这种方式。

<dependency>
    <groupId>org.glassfish.jersey.containers</groupId>
    <artifactId>jersey-container-grizzly2-http</artifactId>
    <version>2.25.1</version>
</dependency>
 
<dependency>
    <groupId>org.glassfish.jersey.containers</groupId>
    <artifactId>jersey-container-grizzly2-servlet</artifactId>
    <version>2.25.1</version>
</dependency>
 
<dependency>
    <groupId>org.glassfish.jersey.containers</groupId>
    <artifactId>jersey-container-jdk-http</artifactId>
    <version>2.25.1</version>
</dependency>
 
<dependency>
    <groupId>org.glassfish.jersey.containers</groupId>
    <artifactId>jersey-container-simple-http</artifactId>
    <version>2.25.1</version>
</dependency>
 
<dependency>
    <groupId>org.glassfish.jersey.containers</groupId>
    <artifactId>jersey-container-jetty-http</artifactId>
    <version>2.25.1</version>
</dependency>
 
<dependency>
    <groupId>org.glassfish.jersey.containers</groupId>
    <artifactId>jersey-container-jetty-servlet</artifactId>
    <version>2.25.1</version>
</dependency

 

3. Jersey模块:

Table 2.1. Jersey Core

Jersey Core
jersey-client Jersey core client implementation
jersey-common Jersey core common packages
jersey-server Jersey core server implementation

 

Table 2.2. Jersey Containers

Jersey Containers
jersey-container-grizzly2-http Grizzly 2 Http Container.
jersey-container-grizzly2-servlet Grizzly 2 Servlet Container.
jersey-container-jdk-http JDK Http Container
jersey-container-jetty-http Jetty Http Container
jersey-container-jetty-servlet Jetty Servlet Container
jersey-container-netty-http Netty Http Container.
jersey-container-servlet Jersey core Servlet 3.x implementation
jersey-container-servlet-core Jersey core Servlet 2.x implementation
jersey-container-simple-http Simple Http Container
jersey-gf-ejb Jersey EJB for GlassFish integration

 

Table 2.3. Jersey Connectors

Jersey Connectors
jersey-apache-connector Jersey Client Transport via Apache
jersey-grizzly-connector Jersey Client Transport via Grizzly
jersey-jetty-connector Jersey Client Transport via Jetty
jersey-netty-connector Jersey Client Transport via Netty

 

Table 2.4. Jersey Media

Jersey Media
jersey-media-jaxb JAX-RS features based upon JAX-B.
jersey-media-json-jackson Jersey JSON Jackson (2.x) entity providers support module.
jersey-media-json-jackson1 Jersey JSON Jackson (1.x) entity providers support module.
jersey-media-json-jettison Jersey JSON Jettison entity providers support module.
jersey-media-json-processing Jersey JSON-P (JSR 353) entity providers support proxy module.
jersey-media-kryo Jersey/JAX-RS Message Body Writer and Reader using Kryo serialization framework
jersey-media-moxy Jersey JSON entity providers support module based on EclipseLink MOXy.
jersey-media-multipart Jersey Multipart entity providers support module.
jersey-media-sse Jersey Server Sent Events entity providers support module.

 

Table 2.5. Jersey Extensions

Jersey Extensions
jersey-bean-validation Jersey extension module providing support for Bean Validation (JSR-349) API.
jersey-cdi1x Jersey CDI 1.1 integration
jersey-cdi1x-ban-custom-hk2-binding Jersey CDI integration - this module disables custom HK2 bindings
jersey-cdi1x-servlet Jersey CDI 1.x Servlet Support
jersey-cdi1x-transaction Jersey CDI 1.x Transactional Support
jersey-cdi1x-validation Jersey CDI 1.x Bean Validation Support
jersey-declarative-linking Jersey support for declarative hyperlinking.
jersey-entity-filtering Jersey extension module providing support for Entity Data Filtering.
jersey-metainf-services Jersey extension module enabling automatic registration of JAX-RS providers (MBW/MBR/EM) via META-INF/services mechanism.
jersey-mvc Jersey extension module providing support for MVC.
jersey-mvc-bean-validation Jersey extension module providing support for Bean Validation in MVC.
jersey-mvc-freemarker Jersey extension module providing support for Freemarker templates.
jersey-mvc-jsp Jersey extension module providing support for JSP templates.
jersey-mvc-mustache Jersey extension module providing support for Mustache templates.
jersey-proxy-client Jersey extension module providing support for (proxy-based) high-level client API.
jersey-rx-client Jersey Reactive Client extension implementation.
jersey-rx-client-guava Jersey Reactive Client - Guava (ListenableFuture) provider.
jersey-rx-client-java8 Jersey Reactive Client - Java 8 (CompletionStage) provider.
jersey-rx-client-jsr166e Jersey Reactive Client - JSR-166e, pre-Java 8, (CompletableFuture) provider.
jersey-rx-client-rxjava Jersey Reactive Client - RxJava (Observable) provider.
jersey-servlet-portability Library that enables writing web applications that run with both Jersey 1.x and Jersey 2.x servlet containers.
jersey-spring3 Jersey extension module providing support for Spring 3 integration.
jersey-wadl-doclet A doclet that generates a resourcedoc xml file: this file contains the javadoc documentation of resource classes, so that this can be used for extending generated wadl with useful documentation.
jersey-weld2-se WELD 2.x SE support

 

Table 2.6. Jersey Test Framework

Jersey Test Framework
container-runner-maven-plugin The container runner maven plugin provides means to start and stop a container (currently, Weblogic, Tomcat and Glassfish4 are supported). To deploy an application to this container or to repetitively redeploy and test an application in the container.
custom-enforcer-rules Jersey test framework Maven projects
jersey-test-framework-core Jersey Test Framework Core
jersey-test-framework-provider-bundle Jersey Test Framework Providers Bundle
jersey-test-framework-provider-external Jersey Test Framework - External container
jersey-test-framework-provider-grizzly2 Jersey Test Framework - Grizzly2 container
jersey-test-framework-provider-inmemory Jersey Test Framework - InMemory container
jersey-test-framework-provider-jdk-http Jersey Test Framework - JDK HTTP container
jersey-test-framework-provider-jetty Jersey Test Framework - Jetty HTTP container
jersey-test-framework-provider-netty Jersey Test Framework - Netty container
jersey-test-framework-provider-simple Jersey Test Framework - Simple HTTP container
jersey-test-framework-util Jersey Test Framework Utils
memleak-test-common Jersey test framework umbrella project

 

Table 2.7. Jersey Test Framework Providers

Jersey Test Framework Providers
jersey-test-framework-provider-bundle Jersey Test Framework Providers Bundle
jersey-test-framework-provider-external Jersey Test Framework - External container
jersey-test-framework-provider-grizzly2 Jersey Test Framework - Grizzly2 container
jersey-test-framework-provider-inmemory Jersey Test Framework - InMemory container
jersey-test-framework-provider-jdk-http Jersey Test Framework - JDK HTTP container
jersey-test-framework-provider-jetty Jersey Test Framework - Jetty HTTP container
jersey-test-framework-provider-netty Jersey Test Framework - Netty container
jersey-test-framework-provider-simple Jersey Test Framework - Simple HTTP container

 

Table 2.8. Jersey Glassfish Bundles

Jersey Glassfish Bundles
jersey-gf-ejb Jersey EJB for GlassFish integration

 

Table 2.9. Security

Security
oauth1-client Module that adds an OAuth 1 support to Jersey client.
oauth1-server Module that adds an OAuth 1 support to Jersey server
oauth1-signature OAuth1 signature module
oauth2-client Module that adds an OAuth 2 support to Jersey client

 

Table 2.10. Jersey Examples

Jersey Examples
additional-bundle OSGi Helloworld Webapp - additional bundle
alternate-version-bundle OSGi Helloworld Webapp - alternate version bundle
assemblies Jersey examples shared assembly types.
bean-validation-webapp Jersey Bean Validation (JSR-349) example.
bookmark Jersey Bookmark example.
bookmark-em Jersey Bookmark example using EntityManager.
bookstore-webapp Jersey MVC Bookstore example.
bundle OSGi HttpService example bundle
cdi-webapp Jersey CDI example.
clipboard Jersey clipboard example.
clipboard-programmatic Jersey programmatic resource API clipboard example.
declarative-linking Declarative Hyperlinking - Jersey Sample
entity-filtering Jersey Entity Data Filtering Example.
entity-filtering-security Jersey Entity Data Filtering Security Example.
entity-filtering-selectable Jersey Entity Data Filtering Selectable Example.
exception-mapping Jersey example showing exception mappers in action.
extended-wadl-webapp Extended WADL example.
feed-combiner-java8-webapp Jersey Web Application (Servlet) examples parent POM.
flight-management-webapp Jersey Flight Management Demo Web Application Example
freemarker-webapp Jersey Freemarker example.
functional-test Jersey examples
functional-test OSGi HttpService example
groovy Groovy Jersey
helloworld Jersey annotated resource class "Hello world" example.
helloworld-benchmark Jersey "Hello World" benchmark example.
helloworld-netty Jersey "Hello world" example on Netty container.
helloworld-programmatic Jersey programmatic resource API "Hello world" example.
helloworld-pure-jax-rs Example using only the standard JAX-RS API's and the lightweight HTTP server bundled in JDK.
helloworld-spring-annotations Spring 3 Integration Jersey Example
helloworld-spring-webapp Spring 3 Integration Jersey Example
helloworld-webapp Jersey annotated resource class "Hello world" example.
helloworld-weld Jersey annotated resource class "Hello world" example with Weld support.
http-patch Jersey example for implementing generic PATCH support via JAX-RS reader interceptor. Taken from Gerard Davison's blog entry: http://kingsfleet.blogspot.co.uk/2014/02/transparent-patch-support-in-jax-rs-20.html
http-trace Jersey HTTP TRACE support example.
https-clientserver-grizzly Jersey HTTPS Client/Server example on Grizzly.
https-server-glassfish Jersey HTTPS server on GlassFish example.
java8-webapp Java 8 Types WebApp Example.
jaxb Jersey JAXB example.
jaxrs-types-injection Jersey JAX-RS types injection example.
jersey-ejb Jersey Web Application (Servlet) examples parent POM.
json-jackson Jersey JSON with Jackson example.
json-jackson1 Jersey JSON with Jackson 1.x example.
json-jettison Jersey JSON with Jettison JAXB example.
json-moxy Jersey JSON with MOXy example.
json-processing-webapp Jersey JSON-P (JSR 353) example.
json-with-padding Jersey JSON with Padding example.
lib-bundle OSGi Helloworld Webapp - lib bundle
managed-beans-webapp Jersey Managed Beans Web Application Example.
managed-client Jersey managed client example.
managed-client-simple-webapp Jersey Web Application (Servlet) examples parent POM.
managed-client-webapp Jersey managed client web application example.
monitoring-webapp Jersey Web Application (Servlet) examples parent POM.
multipart-webapp Jersey Multipart example.
oauth-client-twitter Twitter client using OAuth 1 support for Jersey that retrieves Tweets from the home timeline of a registered Twitter account.
oauth2-client-google-webapp Google API data retrieving example using OAuth2 for authentication and authorization
osgi-helloworld-webapp Jersey examples
osgi-http-service OSGi HttpService example
reload Jersey resource configuration reload example.
rx-client-java8-webapp Jersey Reactive Client Extension (Java8) WebApp Example.
rx-client-webapp Jersey Reactive Client Extension WebApp Example.
server-async Jersey JAX-RS asynchronous server-side example.
server-async-managed Jersey JAX-RS asynchronous server-side example with custom Jersey executor providers.
server-async-standalone Standalone Jersey JAX-RS asynchronous server-side processing example.
server-async-standalone-client Standalone Jersey JAX-RS asynchronous server-side processing example client.
server-async-standalone-webapp Standalone Jersey JAX-RS asynchronous server-side processing example web application.
server-sent-events Jersey Server-Sent Events example.
servlet3-webapp Jersey Servlet 3 example with missing servlet-class in the web.xml file
shortener-webapp Jersey Shortener Webapp (MVC + Bean Validation).
simple-console Jersey Simple Console example
sparklines Jersey examples
sse-item-store-webapp Jersey SSE-based item store example.
sse-twitter-aggregator Jersey SSE Twitter Message Aggregator Example.
system-properties-example Jersey system properties example.
tone-generator Jersey examples
war-bundle OSGi Helloworld Webapp WAR bundle
webapp-example-parent Jersey Web Application (Servlet) examples parent POM.
xml-moxy Jersey XML MOXy example.

转载于:https://my.oschina.net/javastorm/blog/877036

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值