java.lang.NoClassDefFoundError:在eclipse中maven [英] java.lang.NoClassDefFoundError: in eclipse maven
问题描述
<依赖性>
< groupId> xyz-core< / groupId>
< artifactId> xyz-core< / artifactId>
< version> 0< / version>
< scope> system< / scope>
< systemPath> /home/xyz/xyz-core.jar< / systemPath>
< / dependency>
在这个jar文件中,我有一个在我的应用程序中使用的界面。
当我在tomcat服务器上运行我的应用程序时,会显示该界面的异常
异常发送上下文初始化事件到类
org.springframework.web.context.ContextLoaderListener的监听器实例
java.lang.NoClassDefFoundError:com / mxgraph / canvas / mxICanvas2D
而 mxICanvas2D
是一个界面。
这很可能是因为您将范围设置为 system
。根据 Maven文档:
系统
此范围类似于
提供的
除了你必须提供明确包含它的JAR。该工件始终可用,并且不会在存储库中查找。
换句话说,依赖关系不会放在你的类路径上如果您使用系统
,则运行应用程序;你必须自己做。
使用其他范围之一,例如 compile
。
In eclipse with maven, I have add a dependency as a local jar file, as like this:
<dependency>
<groupId>xyz-core</groupId>
<artifactId>xyz-core</artifactId>
<version>0</version>
<scope>system</scope>
<systemPath>/home/xyz/xyz-core.jar</systemPath>
</dependency>
In this jar file I have a interface that is using in my application.
When I run my application on tomcat server It show exception for that interface
Exception sending context initialized event to listener instance of class
org.springframework.web.context.ContextLoaderListener
java.lang.NoClassDefFoundError: com/mxgraph/canvas/mxICanvas2D
while mxICanvas2D
is a interface.
This is most likely because you have set the scope to system
. According to the 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.
In other words, the dependency is not put on your classpath when you run your application if you use system
; you have to do that yourself.
Use one of the other scopes, for example compile
.
这篇关于java.lang.NoClassDefFoundError:在eclipse中maven的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!