泽西岛:“缺少对方法的依赖......”

时间:2012-02-21 01:09:09

标签: maven jetty jersey

有人可以解释一下这个错误的含义吗?

INFO: Scanning for root resource and provider classes in the Web app resource paths:
  /WEB-INF/lib
  /WEB-INF/classes
Feb 21, 2012 3:03:48 AM com.sun.jersey.api.core.ScanningResourceConfig logClasses
INFO: Root resource classes found:
  class com.foo.dom2jcr.rest.XMLCRUDRestlet
Feb 21, 2012 3:03:48 AM com.sun.jersey.api.core.ScanningResourceConfig init
INFO: No provider classes found.
Feb 21, 2012 3:03:48 AM com.sun.jersey.server.impl.application.WebApplicationImpl _initiate
INFO: Initiating Jersey application, version 'Jersey: 1.11 12/09/2011 10:27 AM'
Feb 21, 2012 3:03:49 AM com.sun.jersey.spi.inject.Errors processErrorMessages
SEVERE: The following errors and warnings have been detected with resource and/or provider classes:
  SEVERE: Missing dependency for method public void com.sun.jersey.json.impl.provider.entity.JSONRootElementProvider.setConfiguration(com.sun.jersey.core.util.FeaturesAndProperties) at parameter at index 0
  SEVERE: Missing dependency for method public void com.sun.jersey.core.provider.jaxb.AbstractJAXBProvider.setConfiguration(com.sun.jersey.core.util.FeaturesAndProperties) at parameter at index 0
  SEVERE: Missing dependency for method public void com.sun.jersey.core.provider.jaxb.AbstractJAXBProvider.setConfiguration(com.sun.jersey.core.util.FeaturesAndProperties) at parameter at index 0
  SEVERE: Missing dependency for method public void com.sun.jersey.json.impl.provider.entity.JSONRootElementProvider.setConfiguration(com.sun.jersey.core.util.FeaturesAndProperties) at parameter at index 0
  SEVERE: Missing dependency for method public void com.sun.jersey.json.impl.provider.entity.JSONJAXBElementProvider.setConfiguration(com.sun.jersey.core.util.FeaturesAndProperties) at parameter at index 0
  SEVERE: Missing dependency for method public void com.sun.jersey.json.impl.provider.entity.JSONJAXBElementProvider.setConfiguration(com.sun.jersey.core.util.FeaturesAndProperties) at parameter at index 0
  SEVERE: Missing dependency for method public void com.sun.jersey.json.impl.provider.entity.JSONListElementProvider.setConfiguration(com.sun.jersey.core.util.FeaturesAndProperties) at parameter at index 0
  SEVERE: Missing dependency for method public void com.sun.jersey.json.impl.provider.entity.JSONListElementProvider.setConfiguration(com.sun.jersey.core.util.FeaturesAndProperties) at parameter at index 0
  SEVERE: Missing dependency for method public void com.sun.jersey.core.provider.jaxb.AbstractJAXBProvider.setConfiguration(com.sun.jersey.core.util.FeaturesAndProperties) at parameter at index 0
[INFO] Started Jetty Server

我正在使用Jersey 1.11 + Jetty 7.6.1.v20120215。 这些是我的依赖:

                <dependency>
                    <groupId>com.sun.jersey</groupId>
                    <artifactId>jersey-bundle</artifactId>
                    <version>1.11</version>
                </dependency>
                <dependency>
                    <groupId>com.sun.jersey</groupId>
                    <artifactId>jersey-client</artifactId>
                    <version>1.11</version>
                </dependency>
                <dependency>
                    <groupId>com.sun.jersey</groupId>
                    <artifactId>jersey-servlet</artifactId>
                    <version>1.11</version>
                </dependency>
                <dependency>
                   <groupId>com.sun.jersey.contribs</groupId>
                   <artifactId>jersey-multipart</artifactId>
                   <version>1.11</version>
                </dependency>

我试着环顾谷歌,但我似乎无法找到原因。

提前致谢!

2 个答案:

答案 0 :(得分:5)

除去

   <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-bundle</artifactId>
        <version>1.11</version>
   </dependency>

你应该没事。

您通过向类路径添加捆绑包和单独的依赖项来混淆Jersey。所以基本上你有两个具有相同名称的类(在这种情况下为“com.sun.jersey.core.util.FeaturesAndProperties”),Jersey运行时期望一个,你提供第二个......反之亦然。

无论如何,当从类路径中删除jersey-bundle时,你应该没问题。

答案 1 :(得分:2)

我在处理分段上传时遇到了类似的问题。经过一些搜索和调查,我发现我使用的是不同版本的jersey-multipart和mimepull jar,它与我项目中使用的球衣束不兼容。

如果您是非maven开发人员,请确保在类路径中添加了以下jar:

  • jersey-multipart-X.jar
  • mimepull-Y.jar

X和Y分别是jersey-multipart和mimepull jar的版本标识符。

*请注意X(jersey-multipart的版本)应与jersey-bundle jar的版本相同。