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.
我使用m2eclipse作为eclipse的maven 2插件。我是maven的新手,所以我的错误可能很简单,尽管搜索并没有为我提供任何解决方案。我可以从命令行运行maven,它可以成功构建。但是,如果我作为一个现有的maven项目导入,或者使用mvn eclipse:eclipse,然后导入,我就会得到POM文件中没有的工件,从而导致根本没有加载maven依赖项。
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.
奇怪的是我有两个项目,都是父pom打包项目的子项目。一个子程序装入所有maven依赖项,而另一个子程序找不到任何依赖项,并说pom文件丢失了构件。同样,我可以从命令行安装并打包它们。
I even tried loading my projects into netbeans which worked flawlessly, however I am required to use eclipse.
我甚至尝试将我的项目加载到netbeans中,它可以完美地工作,但是我需要使用eclipse。
Any ideas on how to fix this?
有什么办法解决这个问题吗?
Update
Directory structure, pom files layout:
目录结构,pom文件布局:
--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.
主要是project ecta和project ectb的父项目。project ectb有project ecta作为依赖项。显然,m2eclipse对这种情况并不满意。一旦我从ProjectB的pom文件中删除对ProjectA的依赖项,eclipse就会找到所有的maven依赖项。
- 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.
然而,我仍然需要project ectb来依赖project ecta。错误消息似乎是m2eclipse在远程repo中查找ProjectA。项目A应该只在.m2目录中,但是我不知道如何告诉m2eclipse在那里查找。
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.
我认为这可能只是一个m2eclipse特有的问题,因为使用命令行中的mvn可以很好地工作,就像我前面说的,netbeans加载项目和依赖项也很好。
7 个解决方案
#1
43
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).
解决方案:在不正确构建的项目中,右键单击项目并选择Properties,然后是Maven。取消选中标有“解析来自工作区项目的依赖项”的框,单击Apply,然后单击OK。再次右键单击您的项目并执行Maven->更新快照(或更新依赖项),当您的项目重新构建时,您的错误应该会消失(如果您启用了自动构建,那么会自动消失)。
#2
20
It sounds like your m2eclipse install is using the embedded Maven, which has its own repository (located under user home) and settings.
这听起来像您的m2eclipse安装使用嵌入的Maven,它有自己的存储库(位于用户的家里)和设置。
If you open up the Maven preferences (Window->Preferences->Maven->Installations, you can add your Maven installation by selecting Add... then browsing to the M2_HOME directory.
如果您打开Maven首选项(窗口->首选项->Maven->安装,您可以通过选择add添加Maven安装)。然后浏览到M2_HOME目录。
偏好截图http://www.sonatype.com/books/m2eclipse-book/reference/figs/web/eclipse_preferences2.png
For more details see the m2eclipse book
有关详细信息,请参阅m2eclipse手册
#3
17
For me maven was downloading the dependency but was unable to add it to the classpath. I saw my .classpath of the project,it didnt have any maven-related entry. When I added
对于我来说,maven正在下载依赖项,但无法将其添加到类路径中。我看到了我的项目的.classpath,它没有任何与maven相关的条目。当我添加
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
the issue got resolved for me.
这个问题为我解决了。
#4
2
One of the reason I found was why it doesn't find a jar from repository might be because the .pom file for that particular jar might be missing or corrupt. Just correct it and try to load from local repository.
我发现的原因之一是它没有从存储库中找到jar,这可能是因为该特定jar的.pom文件可能丢失或损坏。只需修改它并尝试从本地存储库加载。
#5
0
I had problems with using m2eclipse (i.e. it did not appear to be installed at all) but I develop a project using IAM - maven plugin for eclipse supported by Eclipse Foundation (or hosted or something like that).
我在使用m2eclipse时遇到了一些问题(例如,它似乎根本没有安装),但是我使用IAM - maven插件开发了一个项目,该插件用于eclipse Foundation支持的eclipse(或托管的)。
I had sometimes problems as sometimes some strange error appeared for project (it couldn't move something) but simple command (run from eclipse as task or from console) + refresh (F5
) solved all problems:
有时我遇到了一些问题,比如项目出现了一些奇怪的错误(它不能移动什么),但是简单的命令(从eclipse作为任务运行或从控制台运行)+ refresh (F5)解决了所有问题:
mvn clean
However please note that I created project in eclipse. However I modified pom.xml
by hand.
但是请注意,我在eclipse中创建了project。但是我修改砰的一声。xml。
#6
0
Okay I fixed this thing. Had to first convert the projects to Maven Projects, then remove them from the Eclipse workspace, and then re-import them.
我修好了。必须首先将项目转换为Maven项目,然后从Eclipse工作区中删除它们,然后重新导入它们。
#7
0
This could be a problem if you are using a custom 'Settings.xml', with a different <localRepository>
configured in it.
如果您使用的是自定义设置,那么这可能是一个问题。xml',其中配置了不同的
Eclipse will be using the default installation of MAVEN, and will be using the default location for the User to look for the local Maven repository, which on Linux systems would be '/home/${USER}/.m2/'
Eclipse将使用默认的MAVEN安装,并将使用用户查找本地MAVEN存储库的默认位置,在Linux系统上应该是'/home/${User}/.m2/'
Eclipse can be easily configured to use the customized 'Settings.xml', by doing the following: Goto -> Window -> Preferences -> Select 'Maven' -> Select 'User Settings'
可以很容易地将Eclipse配置为使用定制的“设置”。通过以下操作:Goto ->窗口->首选项->选择“Maven”->选择“用户设置”
- Under 'User Settings', select the custom 'Settings.xml' file, for 'User Settings' by clicking 'Browse' and selecting the customized 'Settings.xml'.
- 在“用户设置”下,选择“自定义设置”。通过单击“浏览”并选择自定义的“Settings.xml”来实现“用户设置”。
- Click on 'Update Settings', if the 'Local Repository' Textbox does not show the custom location from the file above, just key in the location and click 'Reindex'.
- 单击“更新设置”,如果“本地存储库”文本框没有显示来自上面文件的自定义位置,只需在位置上键入,然后单击“Reindex”。
- Click 'OK'
- 单击“OK”
After this, you could proceed to select your project from the 'Project Explorer', right click, Select 'Maven' > 'Update Project'. Make sure that your project is selected (ticked) in the Window, and click 'OK'.
之后,您可以继续从“project Explorer”中选择项目,右键单击,选择“Maven”>“Update project”。确保在窗口中选择(勾选)您的项目,并单击“OK”。
This should help to resolve the issue, if using custom 'Settings.xml' for Maven.
如果使用自定义的设置,这将有助于解决这个问题。xml的Maven。
Hope it helps.
希望它可以帮助。
#1
43
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).
解决方案:在不正确构建的项目中,右键单击项目并选择Properties,然后是Maven。取消选中标有“解析来自工作区项目的依赖项”的框,单击Apply,然后单击OK。再次右键单击您的项目并执行Maven->更新快照(或更新依赖项),当您的项目重新构建时,您的错误应该会消失(如果您启用了自动构建,那么会自动消失)。
#2
20
It sounds like your m2eclipse install is using the embedded Maven, which has its own repository (located under user home) and settings.
这听起来像您的m2eclipse安装使用嵌入的Maven,它有自己的存储库(位于用户的家里)和设置。
If you open up the Maven preferences (Window->Preferences->Maven->Installations, you can add your Maven installation by selecting Add... then browsing to the M2_HOME directory.
如果您打开Maven首选项(窗口->首选项->Maven->安装,您可以通过选择add添加Maven安装)。然后浏览到M2_HOME目录。
偏好截图http://www.sonatype.com/books/m2eclipse-book/reference/figs/web/eclipse_preferences2.png
For more details see the m2eclipse book
有关详细信息,请参阅m2eclipse手册
#3
17
For me maven was downloading the dependency but was unable to add it to the classpath. I saw my .classpath of the project,it didnt have any maven-related entry. When I added
对于我来说,maven正在下载依赖项,但无法将其添加到类路径中。我看到了我的项目的.classpath,它没有任何与maven相关的条目。当我添加
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
the issue got resolved for me.
这个问题为我解决了。
#4
2
One of the reason I found was why it doesn't find a jar from repository might be because the .pom file for that particular jar might be missing or corrupt. Just correct it and try to load from local repository.
我发现的原因之一是它没有从存储库中找到jar,这可能是因为该特定jar的.pom文件可能丢失或损坏。只需修改它并尝试从本地存储库加载。
#5
0
I had problems with using m2eclipse (i.e. it did not appear to be installed at all) but I develop a project using IAM - maven plugin for eclipse supported by Eclipse Foundation (or hosted or something like that).
我在使用m2eclipse时遇到了一些问题(例如,它似乎根本没有安装),但是我使用IAM - maven插件开发了一个项目,该插件用于eclipse Foundation支持的eclipse(或托管的)。
I had sometimes problems as sometimes some strange error appeared for project (it couldn't move something) but simple command (run from eclipse as task or from console) + refresh (F5
) solved all problems:
有时我遇到了一些问题,比如项目出现了一些奇怪的错误(它不能移动什么),但是简单的命令(从eclipse作为任务运行或从控制台运行)+ refresh (F5)解决了所有问题:
mvn clean
However please note that I created project in eclipse. However I modified pom.xml
by hand.
但是请注意,我在eclipse中创建了project。但是我修改砰的一声。xml。
#6
0
Okay I fixed this thing. Had to first convert the projects to Maven Projects, then remove them from the Eclipse workspace, and then re-import them.
我修好了。必须首先将项目转换为Maven项目,然后从Eclipse工作区中删除它们,然后重新导入它们。
#7
0
This could be a problem if you are using a custom 'Settings.xml', with a different <localRepository>
configured in it.
如果您使用的是自定义设置,那么这可能是一个问题。xml',其中配置了不同的
Eclipse will be using the default installation of MAVEN, and will be using the default location for the User to look for the local Maven repository, which on Linux systems would be '/home/${USER}/.m2/'
Eclipse将使用默认的MAVEN安装,并将使用用户查找本地MAVEN存储库的默认位置,在Linux系统上应该是'/home/${User}/.m2/'
Eclipse can be easily configured to use the customized 'Settings.xml', by doing the following: Goto -> Window -> Preferences -> Select 'Maven' -> Select 'User Settings'
可以很容易地将Eclipse配置为使用定制的“设置”。通过以下操作:Goto ->窗口->首选项->选择“Maven”->选择“用户设置”
- Under 'User Settings', select the custom 'Settings.xml' file, for 'User Settings' by clicking 'Browse' and selecting the customized 'Settings.xml'.
- 在“用户设置”下,选择“自定义设置”。通过单击“浏览”并选择自定义的“Settings.xml”来实现“用户设置”。
- Click on 'Update Settings', if the 'Local Repository' Textbox does not show the custom location from the file above, just key in the location and click 'Reindex'.
- 单击“更新设置”,如果“本地存储库”文本框没有显示来自上面文件的自定义位置,只需在位置上键入,然后单击“Reindex”。
- Click 'OK'
- 单击“OK”
After this, you could proceed to select your project from the 'Project Explorer', right click, Select 'Maven' > 'Update Project'. Make sure that your project is selected (ticked) in the Window, and click 'OK'.
之后,您可以继续从“project Explorer”中选择项目,右键单击,选择“Maven”>“Update project”。确保在窗口中选择(勾选)您的项目,并单击“OK”。
This should help to resolve the issue, if using custom 'Settings.xml' for Maven.
如果使用自定义的设置,这将有助于解决这个问题。xml的Maven。
Hope it helps.
希望它可以帮助。