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
- Java包名称中单词分隔符的约定是什么? 2022-01-01
- 将log4j 1.2配置转换为log4j 2配置 2022-01-01
- Spring Boot连接到使用仲裁器运行的MongoDB副本集 2022-01-01
- Safepoint+stats 日志,输出 JDK12 中没有 vmop 操作 2022-01-01
- Jersey REST 客户端:发布多部分数据 2022-01-01
- 从 finally 块返回时 Java 的奇怪行为 2022-01-01
- C++ 和 Java 进程之间的共享内存 2022-01-01
- value & 是什么意思?0xff 在 Java 中做什么? 2022-01-01
- 如何使用WebFilter实现授权头检查 2022-01-01
- Eclipse 插件更新错误日志在哪里? 2022-01-01