简体   繁体   English

java.lang.NoClassDefFoundError:Maven 项目

[英]java.lang.NoClassDefFoundError: Maven projects

I have 2 Maven projects in Eclipse (Project 'api' and Project 'otp').我在 Eclipse 中有 2 个 Maven 项目(项目“api”和项目“otp”)。 Project 'api' uses some classes located in Project 'otp'.项目“api”使用位于项目“otp”中的一些类。 I added Project 'otp' in the build path below.我在下面的构建路径中添加了 Project 'otp'。

在此处输入图片说明

Now, in compile time, there are no errors thrown.现在,在编译时,不会抛出任何错误。 But when I try to run the project, the following error occurs.但是当我尝试运行该项目时,出现以下错误。 Why is that?这是为什么? Thank you.谢谢你。

在此处输入图片说明

You added the project, but you aren't picking up its dependencies the way you are when building from maven.您添加了该项目,但您并没有像从 maven 构建时那样获取其依赖项。

You should formalize the dependency in your maven project structure and use the eclipse maven plugin to import the project.你应该在你的 maven 项目结构中形式化依赖,并使用 eclipse maven 插件来导入项目。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM