Java 添加什么 Jersey 依赖项以避免 jersey.repackaged.com.google.common.collect.Maps 的 NoClassDefFoundError
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22069316/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What Jersey dependency to add to avoid NoClassDefFoundError for jersey.repackaged.com.google.common.collect.Maps
提问by Matt
I'm trying to run a a test that extends JerseyTest
but when running it I'm getting a:
我正在尝试运行一个扩展的测试,JerseyTest
但是在运行它时我得到一个:
java.lang.NoClassDefFoundError: jersey/repackaged/com/google/common/collect/Maps
Any idea what dependency I'm missing? I've included the following jersey artifacts in my pom.xml
and jersey.version is 2.5.1:
知道我缺少什么依赖吗?我在我的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>
采纳答案by Greg Kopff
You'll need:
你需要:
<dependency>
<groupId>org.glassfish.jersey.bundles.repackaged</groupId>
<artifactId>jersey-guava</artifactId>
<version>2.6</version>
</dependency>
From http://blog.dejavu.sk/2014/02/21/jersey-2-6-has-been-released-new-and-noteworthy/
来自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
andjersey.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 jersey-guavaas this dependency is widely used in multiple Jersey modules.
Jersey 从用于 JAX-RS 2.0 的 2.6 版和用于 JAX-RS 1.1 的 1.18.1 版开始,不再将 Guava 和 ASM 库传递给您的应用程序。这意味着即使我们仍在内部使用它们,您也可以使用这些库的不同版本。来自这两个库的类经过重新包装,
jersey.repackaged.com.google.common
并jersey.repackaged.objectweb.asm
分别与收缩,以降低排放量。ASM 5 现在是 jersey-server 核心模块的一部分,我们为 Guava 创建了一个单独的包模块jersey-guava,因为这个依赖项广泛用于多个 Jersey 模块。
You're using the Jersey 2.6jersey-test-framework-provider-grizzly2
.
您正在使用 Jersey 2.6jersey-test-framework-provider-grizzly2
。