在 eclipse 和 maven 中,我添加了一个依赖作为本地 jar 文件, 像这样:
<dependency>
<groupId>xyz-core</groupId>
<artifactId>xyz-core</artifactId>
<version>0</version>
<scope>system</scope>
<systemPath>/home/xyz/xyz-core.jar</systemPath>
</dependency>
在这个 jar 文件中,我有一个在我的应用程序中使用的接口(interface)。
当我在 tomcat 服务器上运行我的应用程序时,它显示该接口(interface)的异常
Exception sending context initialized event to listener instance of class
org.springframework.web.context.ContextLoaderListener
java.lang.NoClassDefFoundError: com/mxgraph/canvas/mxICanvas2D
而mxICanvas2D
是一个接口(interface)。
最佳答案
这很可能是因为您已将范围设置为 system
。根据Maven documentation :
system
This scope is similar to
provided
except that you have to provide the JAR which contains it explicitly. The artifact is always available and is not looked up in a repository.
换句话说,如果您使用system
,那么当您运行您的应用程序时,依赖不会放在您的类路径中;你必须自己做。
使用其他作用域之一,例如 compile
。
关于java.lang.NoClassDefFoundError : in eclipse maven 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18670749/