在 Spring 4.0 中使用 Jersey-spring

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21443088/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 06:30:36  来源:igfitidea点击:

Using Jersey-spring with Spring 4.0

springjerseyjersey-2.0

提问by guli

According to you what are the risks of using Spring 4with the jersey-spring3integration module?

根据您的说法,Spring 4jersey-spring3集成模块一起使用有哪些风险?

I have tried to use Spring 4.0 with the jersey spring exampleand the example still works but i'm unable to identify risks linked to this usage.

我尝试将 Spring 4.0 与jersey spring 示例一起使用,该示例仍然有效,但我无法确定与此用法相关的风险。

回答by Michael-O

I have started using Jersey 2.7 and Spring 4.0.x recently in a project. I have setup a context hierarchy to inject beans, so far, I have discovered only one limitiationbut that does not seem relate to Spring 4 but rather to the module itself or the HK2 Spring Bridge.

我最近在一个项目中开始使用 Jersey 2.7 和 Spring 4.0.x。我已经设置了一个上下文层次结构来注入 bean,到目前为止,我只发现了一个限制,但这似乎与 Spring 4无关,而是与模块本身或 HK2 Spring Bridge 相关。

To give more insight about my use. I have a XJC/JAXB-backed which is consumed by a common service, repository and exposed through JAX-WS, and now hopefully through JAX-RS.

更深入地了解我的用途。我有一个 XJC/JAXB 支持,它由公共服务、存储库使用并通过 JAX-WS 公开,现在希望通过 JAX-RS。

The multi-context stuff works now with @Autowiredwith 2.8-SNAPSHOT. I have applied my changes and the 2.8-SNAPSHOTto 2.7. Here is the diff.

多上下文的东西现在@Autowired2.8-SNAPSHOT. 我申请我的变化及2.8-SNAPSHOT2.7。这是差异

Edit (Michael-O; 2014-10-17): Hereis a modified Spring module based off 2.11 with multi-context support.

编辑(Michael-O;2014-10-17):是一个基于 2.11 的修改后的 Spring 模块,具有多上下文支持。

回答by Paul Samsotha

Not an answer to original question, just related information

不是原始问题的答案,只是相关信息

This may be a little premature, but the new Major 3.0 version of Jersey will be using Spring 4, in the new jersey-spring4module. The new Major version will be built with Java 8. Though a new Major version will be released, the 2.x line will still be actively developed to keep support for Java 7

这可能有点为时过早,但 Jersey 的新 Major 3.0 版本将在新jersey-spring4模块中使用 Spring 4 。新的 Major 版本将使用 Java 8 构建。虽然将发布新的 Major 版本,但 2.x 系列仍将积极开发以保持对 Java 7 的支持

I'll update this post once 3.0 has been release.

一旦 3.0 发布,我会更新这篇文章。

For anyone interested, you can see this mailing listto see what the Jersey team has to say about the new 3.x line.

对于任何感兴趣的人,您可以查看此邮件列表,了解 Jersey 团队对新 3.x 产品线的看法。

回答by jspetrak

Not sure if you came across any issues but I currently face one. It is described in other thread.

不确定您是否遇到任何问题,但我目前面临一个问题。它在其他线程中描述。

Simply, using jersey-spring3 2.12 and spring 4.1.0.RELEASE in one maven project leads to following class incompatibility:

简单地说,在一个 Maven 项目中使用 jersey-spring3 2.12 和 spring 4.1.0.RELEASE 会导致以下类不兼容:

2014-09-14 01:15:44.175:WARN:oejuc.AbstractLifeCycle:main: FAILED org.eclipse.jetty.server.handler.HandlerCollection@696
db620[org.eclipse.jetty.server.handler.ContextHandlerCollection@27abb6ca[o.e.j.m.p.JettyWebAppContext@737d100a{/,file:/C
:/Users/Josef/Workspace/TransitCenter/src/main/webapp/,STARTING}{file:/C:/Users/Josef/Workspace/TransitCenter/src/main/w
ebapp/}], org.eclipse.jetty.server.handler.DefaultHandler@6968c1d6, org.eclipse.jetty.server.handler.RequestLogHandler@7
d986d83]: java.lang.NoSuchMethodError: org.springframework.beans.factory.support.DefaultListableBeanFactory.getDependenc
yComparator()Ljava/util/Comparator;
java.lang.NoSuchMethodError: org.springframework.beans.factory.support.DefaultListableBeanFactory.getDependencyComparato
r()Ljava/util/Comparator;
        at org.springframework.context.annotation.AnnotationConfigUtils.registerAnnotationConfigProcessors(AnnotationCon
figUtils.java:136)