开发者

How can I figure out where Maven got an artifact from?

开发者 https://www.devze.com 2023-03-18 13:34 出处:网络
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 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.

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

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"?


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

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

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

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
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号