m2eclipse not finding maven dependencies, artifacts not found(m2eclipse 找不到 Maven 依赖项,找不到工件)
问题描述
我使用 m2eclipse 作为我的 maven 2 Eclipse 插件.我是 maven 的新手,所以我的错误可能很简单,尽管搜索并没有为我提供任何解决方案.我可以从命令行运行 maven 并成功构建.但是,如果我作为现有的 maven 项目导入,或者使用 mvn eclipse:eclipse 然后导入,我会得到在我的 POM 文件中找不到的工件,导致根本没有加载任何 maven 依赖项.
I'm using m2eclipse as my maven 2 plugin for eclipse. I'm brand new to maven, so my mistake might be simple, although searching has not yielded any solutions for me. I can run maven from the command line and it build successfully. However if I import as an existing maven project, or use mvn eclipse:eclipse and then import I get the artifacts not found in my POM file resulting in no maven dependencies being loaded at all.
奇怪的是我有 2 个项目,都是父 pom 打包项目的子项目.一个孩子加载了我所有的 maven 依赖项,而另一个找不到任何依赖项,并说我的 pom 文件缺少工件.同样,我可以从命令行安装和打包它们.
What's odd is that I have 2 projects, both children to a parent pom packaged project. One child loads all my maven dependencies while the other cannot find any and says my pom file is missing artifacts. Again, I can install and package them all just fine from the command line.
我什至尝试将我的项目加载到运行完美的 netbeans 中,但是我需要使用 eclipse.
I even tried loading my projects into netbeans which worked flawlessly, however I am required to use eclipse.
关于如何解决这个问题的任何想法?
Any ideas on how to fix this?
目录结构,pom文件布局:
Directory structure, pom files layout:
--main
--pom.xml (is a pom package that is the parent to two other projects)
--ProjectA
--pom.xml
--ProjectB
--pom.xml
Main 是 ProjectA 和 ProjectB 的父项目.ProjectB 将 ProjectA 作为依赖项.显然 m2eclipse 对这种依赖并不满意.一旦我从 ProjectB 的 pom 文件中删除 ProjectA 的依赖项,eclipse 就会找到所有 maven 依赖项.
Main is the parent project of both ProjectA and ProjectB. ProjectB has ProjectA as a dependency. Apprently m2eclipse is not happy about that depedency. As soon as I remove the dependency of ProjectA from ProjectB's pom file all the maven dependencies are found by eclipse.
- com.company.myproj:app:6.6.0:jar Missing: ---------- 1) com.company.myproj:main:pom:${myproj.version} ---------- 1 required artifact is missing. for artifact: com.company.myproj:main:pom:$
{myproj.version} from the specified remote repositories: apache-incubating (http://people.apache.org/repo/m2-incubating-repository/, releases=true, snapshots=true), central (http://
repo1.maven.org/maven2, releases=true, snapshots=false)
但是,我仍然需要 ProjectB 才能拥有 ProjectA 的依赖项.错误消息似乎是 m2eclipse 在远程仓库中寻找 ProjectA.项目 A 应该只在 .m2 目录中,但我不知道如何告诉 m2eclipse 去那里看.
However, I still need ProjectB to have that dependency for ProjectA. The error message seems to be m2eclipse looking for ProjectA in a remote repo. Project A should only be in .m2 directory, but I'm not sure how to tell m2eclipse to look there.
我认为这可能只是一个 m2eclipse 特定的问题,因为从命令行使用 mvn 可以正常工作,就像我之前所说的,netbeans 可以正常加载项目和依赖项.
I think this may be just a m2eclipse specific issue because using mvn from the command line works fine and like I said previously, netbeans loads the projects and dependencies just fine.
推荐答案
我在其他项目中创建的依赖项中遇到了这个问题.下载的第三方依赖项在构建路径中显示正常,但不是我创建的库.
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.
解决方案:在未正确构建的项目中,右键单击该项目并选择属性,然后选择 Maven.取消选中标有解决工作区项目中的依赖项"的框,点击应用,然后点击确定.再次右键单击您的项目并执行 Maven->Update Snapshots(或 Update Dependencies),当您的项目重新构建时,您的错误应该会消失(如果您启用了自动构建,则会自动消失).
SOLUTION: In the project that is not building correctly, right-click on the project and choose Properties, and then Maven. Uncheck the box labeled "Resolve dependencies from Workspace projects", hit Apply, and then OK. 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).
这篇关于m2eclipse 找不到 Maven 依赖项,找不到工件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:m2eclipse 找不到 Maven 依赖项,找不到工件
基础教程推荐
- 设置 bean 时出现 Nullpointerexception 2022-01-01
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01
- Java:带有char数组的println给出乱码 2022-01-01
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01
- 如何使用 Java 创建 X509 证书? 2022-01-01
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01
- 降序排序:Java Map 2022-01-01
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01