本文介绍了使用 Maven 强制重新下载发布依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我正在开发一个依赖于 X 的项目.X 反过来又依赖于 Y.

I'm working on a project with dependency X. X, in turn, depends on Y.

我曾经在我的项目的 pom.xml 中明确包含 Y.然而,它没有被使用,为了让事情更清晰,我将它作为依赖添加到 X 的 pom 中.X 被标记为发布依赖项.

I used to explicitly include Y in my project's pom. However, it was not used and to make things cleaner, I instead added it to X's pom as a dependency. X is marked as a release dependency.

问题是,从我的项目的 pom 中删除 Y 并将其添加到 X 的 pom 后,我的项目没有在 mvn -U clean package 上找到它.我知道 -U 更新快照但不知道发布.

The problem is that after removing Y from my project's pom and adding it to X's pom, my project isn't picking it up on mvn -U clean package. I know -U update snapshots but not releases.

那么,不删除 ~/.m2/repository 目录如何强制重新下载 X 的 pom?另外,我尝试运行 dependency:purge-local-repository 并且它也不起作用.

So, without deleting the ~/.m2/repository directory how can I force a re-download of X's pom? Also, I tried running dependency:purge-local-repository and it didn't work either.

推荐答案

您不能让 Maven 重新下载依赖项,但您可以做的是清除使用 mvn dependency:purge-local 错误下载的依赖项-存储库

You cannot make Maven re-download dependencies, but what you can do instead is to purge dependencies that were incorrectly downloaded using mvn dependency:purge-local-repository

参见:http://maven.apache.org/plugins/maven-dependency-plugin/purge-local-repository-mojo.html

这会查找当前项目的所有传递依赖项的列表,删除它们,然后重新下载它们.如果你想在每次构建时都运行它,你甚至可以将它作为插件添加到你的 pom 中.

This looks up the list of all transitive dependencies of the current project, deletes them, then redownloads them. You can even add it as a plugin into your pom if you want to run it with every build.

这篇关于使用 Maven 强制重新下载发布依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 22:13