m2eclipse没有找到maven依赖,没有找到工件 [英] m2eclipse not finding maven dependencies, artifacts not found

查看:131
本文介绍了m2eclipse没有找到maven依赖,没有找到工件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用m2eclipse作为我的maven 2插件为eclipse。我是全新的maven,所以我的错误可能很简单,虽然搜索没有为我提供任何解决方案。我可以从命令行运行maven并构建成功。但是,如果我作为一个现有的maven项目导入,或者使用mvn eclipse:eclipse然后导入,我得到在我的POM文件中找不到的工件,导致没有加载任何maven依赖。



什么奇怪的是我有2个项目,两个孩子都是父母pom打包的项目。一个孩子加载我所有的maven依赖关系,而另一个孩子不能找到任何东西,并说我的pom文件缺少工件。再次,我可以从命令行安装和打包它们都很好。



我甚至尝试将我的项目加载到netbeans,这个工作完美无缺,但是我需要使用eclipse



有关如何解决这个问题的任何想法?



更新



目录结构,pom文件布局:

   -  main 
--pom.xml(is一个pom包是另外两个项目的父项)
--ProjectA
--pom.xml
--ProjectB
--pom.xml

Main是ProjectA和ProjectB的父项目。 ProjectB将ProjectA作为依赖。对于这个遗留问题,m2eclipse并不满意。一旦我从ProjectB的pom文件中删除ProjectA的依赖关系,eclipse就可以找到所有的maven依赖项。

   -  com.company .myproj:app:6.6.0:jar Missing:---------- 1)com.company.myproj:main:pom:$ {myproj.version} ---------- 1需要的工件丢失。对于工件:com.company.myproj:main:pom:$ 
{myproj.version}从指定的远程存储库:apache-incubating(http://people.apache.org/repo/m2-incubating-repository /,releases = true,snapshots = true),central(http://
repo1.maven.org/maven2,releases = true,snapshots = false)
pre>

但是,我仍然需要ProjectB具有ProjectA的依赖关系。错误消息似乎是m2eclipse在远程repo中寻找ProjectA。项目A只能在.m2目录中,但我不知道如何告诉m2eclipse来看看。



我认为这可能只是一个m2eclipse的具体问题,因为使用命令行中的mvn工作正常,就像我之前说过的,netbeans加载项目和依赖关系很好。 / p>

解决方案

我在其他项目中创建了依赖关系的问题。下载的第三方依赖关系在构建路径中显示良好,但不是我创建的库。



解决方案:在未正确构建的项目中,右键单击该项目并选择Properties,然后选择Maven。取消选中标记为从Workspace项目中解析依赖关系的框,然后单击应用,然后单击确定。在项目上再次右键单击并执行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.

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.

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?

Update

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 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)

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.

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.

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依赖,没有找到工件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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