Eclipse m2eclipse 从本地存储库获取依赖项

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2814555/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 19:23:16  来源:igfitidea点击:

Eclipse m2eclipse getting dependencies from local repository

eclipsemaven-2m2eclipse

提问by wuntee

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?

我在我的机器上安装了本地依赖项(~/.m2/repository/blah/blah/blah)并且 m2eclipse 没有识别它们 - 我认为 m2eclipse 正在使用它自己的 maven 实例。有没有办法强制m2eclipse在osx中​​使用本地maven安装?

回答by Delicia Brummitt

I had the same problem, and this is what worked for me. Using Eclipse Indigo:

我遇到了同样的问题,这对我有用。使用 Eclipse Indigo:

Windows->Show View->Other

窗口->显示视图->其他

In the pop-up: Maven->Maven Repositories

在弹出窗口中:Maven->Maven Repositories

Once the view is displayed, right click on the appropriate repo, and select "Rebuild Index"

显示视图后,右键单击相应的存储库,然后选择“重建索引”

Wait a few seconds and done!

等待几秒钟,完成!

回答by Pascal Thivent

I have dependencies installed local on my machine (~/.m2/repository/blah/blah/blah) and m2eclipse is not recognizing them as there.

我在我的机器上安装了本地依赖项(~/.m2/repository/blah/blah/blah)并且 m2eclipse 没有将它们识别为那里。

Do they have good metadata? How did you install them? Because m2eclipse definitely uses your local repository for dependency resolution.

他们有好的元数据吗?你是如何安装它们的?因为 m2eclipse 肯定会使用您的本地存储库进行依赖项解析。

I think m2eclipse is using its own maven instance. Is there any way to force m2eclipse to use the local maven installation in osx?

我认为 m2eclipse 正在使用它自己的 maven 实例。有没有办法强制m2eclipse在osx中​​使用本地maven安装?

Yes, m2eclipse uses its own version of Maven by default and you can add an external installation via Window > Preferences > Maven > Installationsbut this won't change anything to the local repository used by one or the other that you can configure via Window > Preferences > Maven > User Settingsas shown below:

是的,默认情况下,m2eclipse 使用它自己的 Maven 版本,您可以通过Window > Preferences > Maven > Installations添加外部安装,但这不会对您可以通过Window >配置的一个或另一个使用的本地存储库进行任何更改Preferences > Maven > User Settings如下图:

alt text http://www.imagebanana.com/img/w5y2vevt/screenshot_008.png

替代文字 http://www.imagebanana.com/img/w5y2vevt/screenshot_008.png

This send us back to the questions above: how did you "install" the problematic dependencies?

这让我们回到上面的问题:您是如何“安装”有问题的依赖项的?

回答by Bananeweizen

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.

您可以在 Windows->Preferences->Maven->Installations 中更改使用的 Maven 实例。但是我不确定这是否会有所帮助,因为该设置下面的评论说依赖项解析仍将通过内部 Maven 安装完成。

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

如果我是你,我会尝试将该本地存储库添加到已知存储库列表中。使用 Window->Show View->Maven repositories(遗憾的是在首选项中看不到)。

回答by s_t_e_v_e

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.

检查 jar 是否已正确安装。当您在安装到本地存储库时提供不正确的 jar 路径时,Maven 不会给出错误。当我运行下面的命令时,jgravatar.jar 不在我的 ~ 目录中。

mvn install:install-file -Dfile=~/jgravatar.jar -DgroupId=jgravatar -DartifactId=jgravatar -Dversion=06292012 -Dpackaging=jar

[INFO] Installing /Users/steve/~/jgravatar.jar to /Users/steve/.m2/repository/jgravatar/jgravatar/06292012/jgravatar-06292012.jar
[INFO] Installing /var/folders/gz/gjyqtkzj3ys8lpmh_38qvmn00000gq/T/mvninstall2662938607942511865.pom to /Users/steve/.m2/repository/jgravatar/jgravatar/06292012/jgravatar-06292012.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------

回答by Garet Jax

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.

我遇到了完全相同的问题。我通过 install-file 命令将 JAR 添加到本地存储库。我确认它们已安装。我重建了索引。我转到该目录并使用 7Zip 检查了 JAR 文件,但是我无法让它出现在我的 Eclipse 项目内的 Maven 依赖项中。

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:

对我来说,解决方案非常愚蠢。当我使用依赖项编辑器将依赖项添加到 pom.xml 中时,Maven 将打包节放入 XML 中。所以 XML 条目看起来像:

    <dependency>
        <groupId>slf4j</groupId>
        <artifactId>jdk14</artifactId>
        <version>1.5.8</version>
        <type>JAR</type>
    </dependency>

When I removed the last stanza "JAR" and made the entry:

当我删除最后一节“JAR”并输入时:

    <dependency>
        <groupId>slf4j</groupId>
        <artifactId>jdk14</artifactId>
        <version>1.5.8</version>
    </dependency>

it all worked fine.

一切正常。