【问题标题】:Jetty wants Jersey, but I'm not using itJetty 想要泽西岛,但我没有使用它
【发布时间】:2016-06-21 16:31:19
【问题描述】:

按照此处的说明构建一个相对简单的码头应用程序:

http://www.eclipse.org/jetty/documentation/9.4.x/maven-and-jetty.html

我没有使用 Jersey,但 mvn jetty:run 抱怨

Provider com.sun.jersey.server.impl.container.servlet.JerseyServletContainerInitializer not found

我的 pom.xml 不包含对泽西岛的任何引用。其实很简单:

<dependency>
  <groupId>org.eclipse.jetty</groupId>
  <artifactId>jetty-server</artifactId>
  <version>${jettyVersion}</version>
</dependency>
<dependency>
  <groupId>org.apache.solr</groupId>
  <artifactId>solr-solrj</artifactId>
  <version>6.0.1</version>
</dependency>

是什么让码头寻找泽西岛?

【问题讨论】:

  • mvn dependency:tree 告诉你什么?
  • mvn 依赖:树输出:pastebin.com/kwMbBzH2
  • 您知道您可以编辑您的问题并将粘贴内容添加到其中,对吗?至于你的问题,有一个依赖来自某个地方,其中包含 jersey 依赖。要么在项目依赖中,要么在项目的jetty-maven-plugin依赖设置中。

标签: java maven jersey jetty


【解决方案1】:

在所有依赖项中搜索 META-INF/services/javax.servlet.ServletContainerInitializer 文件。

具有com.sun.jersey.server.impl.container.servlet.JerseyServletContainerInitializer 条目的那个是给您带来问题的那个。

查看您的项目依赖项(又名&lt;project&gt;&lt;dependencies&gt;您项目的jetty-maven-plugin 配置,看看&lt;plugin&gt; 是否添加了任何额外的依赖项(又名&lt;plugin&gt;&lt;dependencies&gt;)。

【讨论】:

  • 感谢您的帮助,乔金!在遵循您的建议后,我偶然发现了一个令人惊讶的发现:克隆我的 repo 并运行 mvn jetty:run 作为另一个用户工作正常。每个用户在哪里/如何配置码头?
【解决方案2】:

好吧,经过多次诡计和咬牙切齿,我想我偶然发现了答案。在学习 maven 的同时,我正在玩带阴影的 uber-jars。我已经将其中一个包编译为一个超级jar,并安装了它。当 maven 把它们放在一起时,它增加了一点,破坏了我的依赖。删除用于本地安装的阴影 jar 并仅将其用于分发就可以了。

【讨论】:

    猜你喜欢
    • 2011-12-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-06
    • 1970-01-01
    • 2011-08-02
    相关资源
    最近更新 更多