为什么maven 2会尝试下载我已经拥有的依赖项?

时间:2022-02-04 19:54:38

When I launch the "mvn install" command, maven sometimes tries to download dependencies that it has already downloaded. That's expected for SNAPSHOT but why does maven do that for other JARs?

当我启动“mvn install”命令时,maven有时会尝试下载已经下载的依赖项。这是SNAPSHOT的预期,但为什么maven会为其他JAR做到这一点?

I know I can avoid that behavior by "-o" flag but I just wonder what the cause is.

我知道我可以通过“-o”标志来避免这种行为,但我只是想知道原因是什么。

4 个解决方案

#1


9  

I'd look for dependencies that don't have a specified version number. Maven will periodically check to make sure that it has the most up-to-date version of these artifacts.

我会查找没有指定版本号的依赖项。 Maven将定期检查以确保它具有这些工件的最新版本。

#2


3  

This is probably not what you're seeing, but in the past I've had to manually install artifacts into my local repository and if you forget to include the -Dgenerate.pom=true option there will be no pom in the repo for that artifact and Maven will go out to central (and any other remote repos you have configured) to try to download that pom on every build.

这可能不是你所看到的,但在过去我不得不手工将工件安装到我的本地存储库中,如果你忘记包含-Dgenerate.pom = true选项,那么repo中就没有pom artifact和Maven会去中心(以及你配置的任何其他远程repos)尝试在每次构建时下载pom。

#3


2  

While we're on the subject of this, I've run into a major bug in Maven 2.0.x. In offline mode, maven will still attempt to download the latest snapshot, and when it can't find your snapshot repo, it fails the build. Imagine the hilarity that ensues when this happens on site with a client and you just needed to make a small change (but I digress).

虽然我们讨论的是这个问题,但我遇到了Maven 2.0.x中的一个主要错误。在离线模式下,maven仍会尝试下载最新的快照,当它无法找到您的快照存储库时,它将无法进行构建。想象一下,当客户在现场发生这种情况时会发生的欢闹,你只需做一个小改动(但我离题了)。

Here's the bug: http://jira.codehaus.org/browse/MNG-2433 here's a workaround: http://mail-archives.apache.org/mod_mbox/maven-users/200601.mbox/%3C117228810601130559l7e79a5e2k@mail.gmail.com%3E

这是错误:http://jira.codehaus.org/browse/MNG-2433这里有一个解决方法:http://mail-archives.apache.org/mod_mbox/maven-users/200601.mbox/%3C117228810601130559l7e79a5e2k@mail。 gmail.com%3E

#4


0  

The -o flag still wasn't working for me, but this did:

-o标志仍然不适合我,但这样做:

find ~/.m2/repository -name '_maven*' | xargs rm
find ~/.m2/repository -name '*lastUpdated' | xargs rm

Which will delete all the .lastUpdated and _maven.repositories files in your local repo. I ran into this issue because we have a corporate Nexus repo that was unreachable, and I needed to do some work. Using Eclipse's Maven integration may have also contributed to this.

这将删除本地仓库中的所有.lastUpdated和_maven.repositories文件。我遇到了这个问题,因为我们有一个无法访问的企业Nexus仓库,我需要做一些工作。使用Eclipse的Maven集成可能也有助于此。

#1


9  

I'd look for dependencies that don't have a specified version number. Maven will periodically check to make sure that it has the most up-to-date version of these artifacts.

我会查找没有指定版本号的依赖项。 Maven将定期检查以确保它具有这些工件的最新版本。

#2


3  

This is probably not what you're seeing, but in the past I've had to manually install artifacts into my local repository and if you forget to include the -Dgenerate.pom=true option there will be no pom in the repo for that artifact and Maven will go out to central (and any other remote repos you have configured) to try to download that pom on every build.

这可能不是你所看到的,但在过去我不得不手工将工件安装到我的本地存储库中,如果你忘记包含-Dgenerate.pom = true选项,那么repo中就没有pom artifact和Maven会去中心(以及你配置的任何其他远程repos)尝试在每次构建时下载pom。

#3


2  

While we're on the subject of this, I've run into a major bug in Maven 2.0.x. In offline mode, maven will still attempt to download the latest snapshot, and when it can't find your snapshot repo, it fails the build. Imagine the hilarity that ensues when this happens on site with a client and you just needed to make a small change (but I digress).

虽然我们讨论的是这个问题,但我遇到了Maven 2.0.x中的一个主要错误。在离线模式下,maven仍会尝试下载最新的快照,当它无法找到您的快照存储库时,它将无法进行构建。想象一下,当客户在现场发生这种情况时会发生的欢闹,你只需做一个小改动(但我离题了)。

Here's the bug: http://jira.codehaus.org/browse/MNG-2433 here's a workaround: http://mail-archives.apache.org/mod_mbox/maven-users/200601.mbox/%3C117228810601130559l7e79a5e2k@mail.gmail.com%3E

这是错误:http://jira.codehaus.org/browse/MNG-2433这里有一个解决方法:http://mail-archives.apache.org/mod_mbox/maven-users/200601.mbox/%3C117228810601130559l7e79a5e2k@mail。 gmail.com%3E

#4


0  

The -o flag still wasn't working for me, but this did:

-o标志仍然不适合我,但这样做:

find ~/.m2/repository -name '_maven*' | xargs rm
find ~/.m2/repository -name '*lastUpdated' | xargs rm

Which will delete all the .lastUpdated and _maven.repositories files in your local repo. I ran into this issue because we have a corporate Nexus repo that was unreachable, and I needed to do some work. Using Eclipse's Maven integration may have also contributed to this.

这将删除本地仓库中的所有.lastUpdated和_maven.repositories文件。我遇到了这个问题,因为我们有一个无法访问的企业Nexus仓库,我需要做一些工作。使用Eclipse的Maven集成可能也有助于此。