x和RESTEasy依赖项的项目

x和RESTEasy依赖项的项目

本文介绍了是否可以使用Jersey 2.x和RESTEasy依赖项的项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个项目,该项目使用各种客户端应用程序作为maven依赖项来与不同的REST API进行通信.

I'm working on a project which uses various client apps as maven dependencies to talk to different REST APIs.

但是,当包含使用Jersey 2.x实现的客户端和使用RESTEasy的任何其他客户端时,会出现问题.

But there's a problem when including a client which is implemented using Jersey 2.x and any other client which is using RESTEasy.

一旦我添加了使用RESTEasy的依赖项,我将得到如下错误:

As soon as I add the dependency which is using RESTEasy I'll get errors like this:

或者这个:

是否可以同时使用这两个库或配置Maven,以使该应用程序不会尝试使用RESTEasy依赖项而不是Jersey 2.x依赖项,反之亦然?

Is is possible to use both libraries or configure maven somehow so that the app won't try to use the RESTEasy dependencies instead of the Jersey 2.x ones and vice versa?

谢谢

丹尼尔

推荐答案

您可以尝试使用Maven配置文件来激活Jersey或RESTEasy,但是您不能在同一平面类路径中的同一位置上同时使用两个JAX-RS实现时间.

You could try to use Maven profiles to activate either Jersey or RESTEasy, but you can't have two JAX-RS implementations in the same flat classpath at the same time.

如果必须在一个应用程序中同时使用这两种实现,则需要由OSGi或JBoss Modules等模块系统提供的类加载器隔离.

If you have to use both implementations simultaneously in one application, you'll need classloader isolation provided by a module system like OSGi or JBoss Modules.

最好的方法可能是将代码重构为仅使用JAX-RS 2.0客户端API,并为出现以下情况的特殊情况解决 Jersey RESTEasy需要特定于实现的API.

The best way to go might be to refactor your code to use only the JAX-RS 2.0 client API and to settle for either Jersey or RESTEasy for corner cases which require implementation-specific APIs.

这篇关于是否可以使用Jersey 2.x和RESTEasy依赖项的项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-28 07:00