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

发布于 2024-09-01 12:39:18 字数 144 浏览 3 评论 0原文

我在我的机器上本地安装了依赖项(~/.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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

心的位置 2024-09-08 12:39:18

我遇到了同样的问题,这对我有用。使用 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!

泅人 2024-09-08 12:39:18

我在我的机器上本地安装了依赖项(~/.m2/repository/blah/blah/blah),并且 m2eclipse 无法识别它们。

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

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

是的,m2eclipse 默认使用自己的 Maven 版本,您可以通过 Window > 添加外部安装首选项>梅文>安装,但这不会改变任何一个或另一个使用的本地存储库,您可以通过窗口 > 进行配置。首选项>梅文>用户设置如下所示:

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

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

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

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

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

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?

猫九 2024-09-08 12:39:18

您可以在 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).

憧憬巴黎街头的黎明 2024-09-08 12:39:18

检查 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] ------------------------------------------------------------------------

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.

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] ------------------------------------------------------------------------
乜一 2024-09-08 12:39:18

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

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

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

当我删除最后一节“JAR”并创建条目时:

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

一切正常。

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:

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

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

it all worked fine.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文