java - 从 jersey 1.18.1 迁移到 jersey 1.19 时出现 NoClassDefFoundError javax/ws/rs/core/Application

标签 java rest web-applications jaxb jersey

当我升级 Jersey 的版本时,我在尝试启动我的网络应用程序时遇到上述异常。 我正在使用 Jersey 库来实现 JAXBContextResolver其中implements ContextResolver<JAXBContext> 。 在异常中我看到:

Caused by: java.lang.NoClassDefFoundError: javax/ws/rs/core/Application.

配置:

<jersey-server.version>1.19</jersey-server.version>
<jersey-core.version>${jersey-server.version}</jersey-core.version>
<jersey-servlet.version>${jersey-server.version}</jersey-servlet.version>
<jersey-json.version>${jersey-server.version}</jersey-json.version>
<jersey-client.version>${jersey-server.version}</jersey-client.version>

代码:

public class JAXBContextResolver implements ContextResolver<JAXBContext> {
private static final Class<?>[] classes = { Customer.class, Model.class,
        User.class, Workspace.class, AuthResponse.class, Category.class,
        CategoryValue.class };
private JAXBContext context;

public JAXBContextResolver() throws Exception {
    context = new JSONJAXBContext(
            JSONConfiguration.natural().humanReadableFormatting(true)
                    .rootUnwrapping(true).build(), classes);
}

public JAXBContext getContext(Class<?> objectType) {
    return context;
  }
}

最佳答案

需要添加jsr311-api的依赖才可以使用。

关于java - 从 jersey 1.18.1 迁移到 jersey 1.19 时出现 NoClassDefFoundError javax/ws/rs/core/Application,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34667021/

相关文章:

java - 使用 Spring(AOP?)实现 Java 接口(interface)

java - 在 Java 1.4 中控制音频剪辑的音量

json - 休息 : different representations of the same data

html - 验证码或不验证码

javascript - 如何验证 JS 脚本在网站中运行需要多长时间?

android - 为移动和桌面编写一个代码库?

java - Spring 在 security-context.xml 中使用 applicationContext 中的 bean

java - 是否有可能中断 Eclipse 调试器中的每个对象引用?

rest - 如何在 REST Web 服务中实现最简单的外星人?

javascript - 从 Angularjs REST 资源发送基于文件的虚拟数据