我如何找出Maven从何处获得工件? [英] How can I figure out where Maven got an artifact from?

查看:113
本文介绍了我如何找出Maven从何处获得工件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只花了半个小时与一位同事一起工作,弄清楚了为什么他(从完全相同的来源工作)却做不到时可以建立一个项目.我知道,关于Maven的故事是一个共同的开端.无论如何,事实证明我们依赖于org.apache.commons:commons-pool之类的东西,而我们指向的存储库仅提供了commons-pool:commons-pool.我们都忽略了很长一段时间的差异,直到我们最终流行起来.我一定能够看到"前者,而他显然不能.

I just spent half an hour working with a colleague to figure out why I could build a project when he (working from the exact same source) could not. Common start to a story about Maven, I know. Anyway, it turns out that we had a dependency on something like org.apache.commons:commons-pool, while the repo we pointed to only supplied commons-pool:commons-pool. We both overlooked the difference for a long time until we finally caught on. I must have been able to "see" the former, while he obviously could not.

所以我的问题是:我怎么能问Maven您从哪里得到X:Y?"

So my question is: how can I ask Maven "where are you getting X:Y from"?

奖金问题:如果仅显示在本地缓存中,有什么方法可以告诉它如何到达那里?我可以告诉Maven仅此一次,以确保您在构建中使用的所有内容也可以从我的远程仓库中获得"吗?

Bonus questions: If it's only showing up in the local cache, is there any way to tell how it got there? Can I tell Maven "just this once, make sure everything you're using in the build is also available from my remote repo"?

推荐答案

也许您的settings.xml上有朋友没有的存储库.

Maybe you have repositories available on your settings.xml that your friend don't.

如Ed Staub所说,您可以尝试通过执行以下操作来清理本地存储库:

As Ed Staub said you can try to clean your local repository by executing:

mvn dependency:purge-local-repository

然后尝试通过运行以下命令下载所有项目依赖项:

After that try to download all your project dependencies by running:

mvn dependency:go-offline

现在,如果您对最后一个目标有疑问,例如找不到工件org.apache.commons:commons-pool,则可以尝试找到其存储库,该存储库将转到 http://www.mvnbrowser.com 并搜索该工件,然后在结果页面上,可以选择 Repositories 标签以查看在何处可以找到该工件(例如JBoss Maven回购).

Now if you have a problem with the last goal saying it could not find for example the artifact org.apache.commons:commons-pool you can try to find its repository going to http://www.mvnbrowser.com and searching for this artifact, then on the results page you can select the tab Repositories to see where you can find this artifact (for example JBoss maven repo).

获取工件组ID(版本)后,您可以通过将当前内容添加到pom.xml中,将项目所在的存储库添加到项目中:

After getting the artifact group, id, version you can add the repository where it's located to your project by adding the current content to your pom.xml:

<repositories>
<repository>
<id>repository.jboss.org-public</id>
<name>JBoss repository</name>
<url>https://repository.jboss.org/nexus/content/groups/public</url>
</repository>
</repositories>

然后,如果您尝试再次下载依赖项,它现在应该可以工作.

Then if you try to download the dependencies again it now should work.

mvn dependency:go-offline

这篇关于我如何找出Maven从何处获得工件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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