Eclipse 项目中缺少 Maven 依赖项 [英] Missing Maven dependencies in Eclipse project

查看:48
本文介绍了Eclipse 项目中缺少 Maven 依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个用 maven 设置的项目来解决依赖关系.它通常工作正常,但现在我尝试在新 PC 上编译和运行它,但我遇到了 Eclipse 中缺少依赖项的问题.

We have a project set up with maven for resolving dependancies. It usually works fine, but now I am trying to compile and run it on a new PC and I have problem with missing dependencies in Eclipse.

有趣的是,如果我在控制台或 Eclipse 中运行mvn package",它运行良好,甚至会产生包含所有必要 jar 的战争.只有 Eclipse 抱怨该项目未构建,因为其构建路径不完整.找不到 org.slf4j.Logger 的类文件...".如果我将项目与其他计算机(项目工作正常)进行比较,我会注意到在 Eclipse 中的Maven 依赖项"列表下缺少很多库.即使它们在打包的战争中,也可以在存储库文件夹下找到.

What is funny is that if I run "mvn package" in console or in eclipse, it works fine and even produces war containing all necessary jars. Only Eclipse complains with "The project was not built since its build path is incomplete. Cannot find the class file for org.slf4j.Logger...". If I compare the project with some other computer (where project works fine), I notice that there are quite a few libraries missing under "Maven dependencies" listing in Eclipse. Eventhough they are in the packaged war and they can be found also under repository folder.

所以,jar-s 在那里,只是 Eclipse 不会在Maven 依赖项"下列出它们.我能做什么?

So, the jar-s are there just Eclipse won't list them all under "Maven dependencies". What can I do?

计算机在 Windows 7 上运行,带有 64 位 java &日食.

Computer is running on Windows 7 with 64bit java & eclipse.

推荐答案

对于在其他项目中创建的依赖项,我遇到了这个问题.下载的第三方依赖项在构建路径中显示正常,但不是我创建的库.

I had this issue for dependencies that were created in other projects. Downloaded thirdparty dependencies showed up fine in the build path, but not a library that I had created.

解决方案:在未正确构建的项目中,

SOLUTION: In the project that is not building correctly,

  • 右键单击项目并选择属性,然后选择 Maven.

  • Right-click on the project and choose Properties, and then Maven.

取消选中标记为从工作区解决依赖关系"的框项目"

点击应用,然后点击确定.

Hit Apply, and then OK.

再次右键单击您的项目并执行 Maven->Update Snapshots(或更新依赖项)

Right-click again on your project and do a Maven->Update Snapshots (or Update Dependencies)

当您的项目重建时,您的错误应该会消失(如果您启用了自动构建,则会自动消失).

And your errors should go away when your project rebuilds (automatically if you have auto-build enabled).

这篇关于Eclipse 项目中缺少 Maven 依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆