Eclipse m2eclipse 从本地存储库获取依赖项
我在我的机器上本地安装了依赖项(~/.m2/repository/blah/blah/blah),并且 m2eclipse 无法识别它们 - 我认为 m2eclipse 正在使用自己的 Maven 实例。有没有办法强制m2eclipse在osx中使用本地maven安装?
I have dependencies installed local on my machine (~/.m2/repository/blah/blah/blah) and m2eclipse is not recognizing them as there - I think m2eclipse is using its own maven instance. Is there any way to force m2eclipse to use the local maven installation in osx?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我遇到了同样的问题,这对我有用。使用 Eclipse Indigo:
Windows->Show View->Other
在弹出窗口中:
Maven->Maven Repositories
显示视图后,右键单击相应的存储库,然后选择“重建索引”,
等待几秒钟即可完成!
I had the same problem, and this is what worked for me. Using Eclipse Indigo:
Windows->Show View->Other
In the pop-up:
Maven->Maven Repositories
Once the view is displayed, right click on the appropriate repo, and select "Rebuild Index"
Wait a few seconds and done!
他们有良好的元数据吗?你是如何安装它们的?因为 m2eclipse 肯定使用您的本地存储库进行依赖关系解析。
是的,m2eclipse 默认使用自己的 Maven 版本,您可以通过 Window > 添加外部安装首选项>梅文>安装,但这不会改变任何一个或另一个使用的本地存储库,您可以通过窗口 > 进行配置。首选项>梅文>用户设置如下所示:
alt text http://www.imagebanana.com/img/w5y2vevt/ Screenshot_008.png
这让我们回到了上面的问题:你是如何“安装”有问题的依赖项的?
Do they have good metadata? How did you install them? Because m2eclipse definitely uses your local repository for dependency resolution.
Yes, m2eclipse uses its own version of Maven by default and you can add an external installation via Window > Preferences > Maven > Installations but this won't change anything to the local repository used by one or the other that you can configure via Window > Preferences > Maven > User Settings as shown below:
alt text http://www.imagebanana.com/img/w5y2vevt/screenshot_008.png
This send us back to the questions above: how did you "install" the problematic dependencies?
您可以在 Windows->Preferences->Maven->Installations 中更改使用的 Maven 实例。但我不确定这是否会有帮助,因为下面的评论表示依赖项解析仍将通过内部 Maven 安装来完成。
如果我是您,我会尝试将该本地存储库添加到已知存储库列表中。使用 Window->Show View->Maven repositories(遗憾的是,这在首选项中不可见)。
You can change the used Maven instance in Windows->Preferences->Maven->Installations. But I'm not sure whether this will help as a comment below that setting says that dependency resolution will still be done with the internal Maven installation.
If I were you, I would try to add that local repository to the list of known repositories. Use Window->Show View->Maven repositories (this is sadly not visible in the preferences).
检查 jar 是否安装正确。当您在安装到本地存储库时提供了不正确的 jar 路径时,Maven 不会给出错误。当我运行下面的命令时,jgravatar.jar 不在我的 ~ 目录中。
Check that the jar was installed properly. Maven does not give an error when you provide an incorrect path to the jar when installing to local repository. The jgravatar.jar was not in my ~ directory when I ran the command below.
我遇到了完全相同的问题。我通过 install-file 命令将 JAR 添加到本地存储库。我确认它们已安装。我重建了索引。我进入该目录并使用 7Zip 检查了 JAR 文件,但无法让它出现在 Eclipse 项目内的 Maven 依赖项中。
对我来说,这个解决方案非常愚蠢。当我使用依赖项编辑器将依赖项添加到 pom.xml 中时,Maven 将打包节放入 XML 中。所以 XML 条目看起来像:
当我删除最后一节“JAR”并创建条目时:
一切正常。
I was getting the exact same issue. I added the JARs to the local repository via the install-file command. I verified they were installed. I rebuilt the index. I went to the directory and inspected the JAR file using 7Zip, but I could not get it to appear in the Maven Dependencies inside of my eclipse project.
For me the solution was pretty silly. When I added the dependency into the pom.xml using the dependencies editor, Maven threw in a packaging stanza into the XML. So the XML entry looked like:
When I removed the last stanza "JAR" and made the entry:
it all worked fine.