【问题标题】:NoClassDefFoundError with jetty-maven-pluginNoClassDefFoundError 与 jetty-maven-plugin
【发布时间】:2011-10-17 23:52:12
【问题描述】:

我得到一个:

他导致 java.lang.NoClassDefFoundError Msg:net/spy/memcached/MemcachedClient

在 eclipse 中执行 jetty:run -e 时。为什么不将此依赖项添加到类路径中?

【问题讨论】:

  • 通过反射调用包含导入的类。有没有办法明确告诉 jetty/jetty-maven-plugin 包含依赖项?

标签: maven jetty


【解决方案1】:

您希望将它添加到哪个类路径?如果您的项目中的某些内容正在尝试加载它,请确保您有一个包含该类的项目依赖项。它看起来像it comes from ServiceMix。如果您向 Jetty 本身添加了一些内容以使其需要该类,那么add the dependency to the jetty plugin

【讨论】:

    【解决方案2】:

    您的代码缺少运行时依赖项。我在 Maven Central 中搜索了缺少的类

    http://search.maven.org/#search|ga|1|fc%3A%22net.spy.memcached.MemcachedClient%22

    尝试将以下内容添加到您的 POM:

    <dependency>
        <groupId>org.apache.servicemix.bundles</groupId>
        <artifactId>org.apache.servicemix.bundles.spymemcached</artifactId>
        <version>2.5_2</version>
        <packaging>bundle</packaging>
    </dependency>
    

    【讨论】:

    • 该类来自 spymemcached,我当然添加了依赖项。我现在正在尝试使用 run-exploded 目标和战争包装来运行 jetty-maven-plugin。战争已与依赖项正确打包,但仍然会发生此错误。我认为 jetty-maven-plugin 失败或 jetty 失败。 Jetty 还警告未解决的忽略 web.xml 消息。
    【解决方案3】:

    依赖项有一个提供的范围。改变这个。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-11-27
      • 2011-05-30
      • 2014-04-23
      • 2011-11-25
      • 2011-02-28
      • 2011-05-08
      • 2016-03-23
      相关资源
      最近更新 更多