如何确定给定 Maven 依赖项的来源?
给定一个本地 Maven 存储库,是否可以确定作为特定依赖项来源的远程存储库?如何?
Given a local Maven repository, can one determine the remote repository that is the source of a particular dependency? How?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
正如 @Eugene 所提到的,依赖项的来源不存储在任何地方,因此事后找到它的唯一方法(如果您不在公司存储库后面)是清除给定项目的依赖项并重新- 解决它们。 Maven 依赖插件 的以下目标可以做到这一点:
请注意
reResolve
默认情况下设置为true
,我只是出于文档目的而提到它。As mentioned by @Eugene, the origin of a dependency isn't stored anywhere so the only way to find this after the fact (if you're not behind a corporate repository) would be to purge the dependencies of a given project and to re-resolve them. The following goal of the Maven Dependency Plugin can do that:
Note that
reResolve
is set totrue
by default, I just mentioned it for documentation purposes.Maven 不存储此类信息。但是,如果您清除本地存储库并运行项目构建,则在 Maven 构建期间下载工件时,您可以看到实际的存储库 url。
但是,如果您使用 Nexus 等 Maven 存储库管理器,您可以按 ID、版本等搜索工件,然后在搜索结果中查看工件源。
Maven don't store such information. However if you purge your local repository and run your project build you can see the actual repository url when artifact is downloaded during Maven build.
However if you are using Maven repository manager like Nexus you can search artifact by its id, version, etc and then see artifact source in the search results.
您可以从本地存储库中删除依赖项,然后在下一个构建中查看它从哪里提取。
You could delete the dependency from your local repository and then see where it pulls from on your next build.