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.commonandjersey.repackaged.objectweb.asmrespectively, 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
基础教程推荐
- RabbitMQ:消息保持“未确认"; 2022-01-01
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
- 修改 void 函数的输入参数,然后读取 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- 存储 20 位数字的数据类型 2022-01-01
- Struts2 URL 无法访问 2022-01-01
- 如何对 Java Hashmap 中的值求和 2022-01-01
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- 使用堆栈算法进行括号/括号匹配 2022-01-01
