【发布时间】:2011-10-17 23:52:12
【问题描述】:
我得到一个:
他导致 java.lang.NoClassDefFoundError Msg:net/spy/memcached/MemcachedClient
在 eclipse 中执行 jetty:run -e 时。为什么不将此依赖项添加到类路径中?
【问题讨论】:
-
通过反射调用包含导入的类。有没有办法明确告诉 jetty/jetty-maven-plugin 包含依赖项?
我得到一个:
他导致 java.lang.NoClassDefFoundError Msg:net/spy/memcached/MemcachedClient
在 eclipse 中执行 jetty:run -e 时。为什么不将此依赖项添加到类路径中?
【问题讨论】:
您希望将它添加到哪个类路径?如果您的项目中的某些内容正在尝试加载它,请确保您有一个包含该类的项目依赖项。它看起来像it comes from ServiceMix。如果您向 Jetty 本身添加了一些内容以使其需要该类,那么add the dependency to the jetty plugin。
【讨论】:
您的代码缺少运行时依赖项。我在 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>
【讨论】:
依赖项有一个提供的范围。改变这个。
【讨论】: