java – 要为jersey.repackaged.com.google.common.collect.Maps避免NoClassDefFoundError而添加的Jersey依赖项

前端之家收集整理的这篇文章主要介绍了java – 要为jersey.repackaged.com.google.common.collect.Maps避免NoClassDefFoundError而添加的Jersey依赖项前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试运行一个扩展JerseyTest的测试但是在运行时我得到了一个:
java.lang.NoClassDefFoundError: jersey/repackaged/com/google/common/collect/Maps

知道我缺少什么依赖吗?我在我的pom.xml中包含了以下球衣工件,而jersey.version是2.5.1:

<dependency>
        <groupId>org.glassfish.jersey.containers</groupId>
        <artifactId>jersey-container-servlet</artifactId>
        <version>${jersey.version}</version>
    </dependency>

    <dependency>
        <groupId>org.glassfish.jersey.core</groupId>
        <artifactId>jersey-client</artifactId>
        <version>${jersey.version}</version>
    </dependency>        

    <dependency>
        <groupId>com.sun.jersey.jersey-test-framework</groupId>
        <artifactId>jersey-test-framework-core</artifactId>
        <version>1.18</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.glassfish.jersey.test-framework.providers</groupId>
        <artifactId>jersey-test-framework-provider-grizzly2</artifactId>
        <version>2.6</version>
        <scope>test</scope>
    </dependency>

解决方法

你需要:
<dependency>
  <groupId>org.glassfish.jersey.bundles.repackaged</groupId>
  <artifactId>jersey-guava</artifactId>
  <version>2.6</version>
</dependency>

http://blog.dejavu.sk/2014/02/21/jersey-2-6-has-been-released-new-and-noteworthy/

Jersey,from versions 2.6 for JAX-RS 2.0 and 1.18.1 for JAX-RS 1.1,no longer transitively brings Guava and ASM libraries to your application. This means that even when we still use them internally you can use different versions of these libraries. Classes from both of these libraries has been repackaged,jersey.repackaged.com.google.common and jersey.repackaged.objectweb.asm respectively,and shrinked to lower the footprint. ASM 5 is now part of jersey-server core module and for Guava we’ve created a separate bundle module 07001 as this dependency is widely used in multiple Jersey modules.

你正在使用Jersey 2.6 jersey-test-framework-provider-grizzly2.

猜你在找的Java相关文章