What Jersey dependency to add to avoid NoClassDefFoundError for jersey.repackaged.com.google.common.collect.Maps(要添加什么 Jersey 依赖项以避免 jersey.repackaged.com.google.common.collect.Maps 的 NoClassDefFoundError)
问题描述
我正在尝试运行一个扩展 JerseyTest
的测试,但运行它时我得到一个:
I'm trying to run a a test that extends JerseyTest
but when running it I'm getting a:
java.lang.NoClassDefFoundError: jersey/repackaged/com/google/common/collect/Maps
知道我缺少什么依赖项吗?我在 pom.xml
中包含了以下球衣工件,并且 jersey.version 是 2.5.1:
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:
<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,从 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 模块中.
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-guava as this dependency is widely used in multiple Jersey modules.
您使用的是 Jersey 2.6 jersey-test-framework-provider-grizzly2
.
You're using the Jersey 2.6 jersey-test-framework-provider-grizzly2
.
这篇关于要添加什么 Jersey 依赖项以避免 jersey.repackaged.com.google.common.collect.Maps 的 NoClassDefFoundError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:要添加什么 Jersey 依赖项以避免 jersey.repackaged.com.google.common.collect.Maps 的 NoClassDefFoundError
基础教程推荐
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01
- Java:带有char数组的println给出乱码 2022-01-01
- 降序排序:Java Map 2022-01-01
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01
- 如何使用 Java 创建 X509 证书? 2022-01-01
- 设置 bean 时出现 Nullpointerexception 2022-01-01