如果失败,Maven 重试依赖项下载 [英] Maven retry dependency download if failed

查看:52
本文介绍了如果失败,Maven 重试依赖项下载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

maven 下载依赖时,其中之一由于网络问题而失败:

下载:https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-failsafe-plugin/2.16/maven-failsafe-plugin-2.16.pom插件 org.apache.maven.plugins:maven-failsafe-plugin:2.16 或其依赖项之一无法解析:无法读取 org.apache.maven.plugins:maven-failsafe-plugin:jar:2.16 的工件描述符

我想重试 n 次,其中 n 将是可配置的.我该怎么做?

解决方案

我在 Gitlab CI/CD 中遇到了类似的问题.这似乎解决了问题:

-Dmaven.wagon.http.retryHandler.count=3

<块引用>

从 3.2 版本开始,可以通过系统配置重试处理程序属性:

...

    • maven.wagon.http.retryHandler.count = 默认或标准实现的重试次数.

此处描述了其他 HTTP 客户端设置:https://maven.apache.org/wagon/wagon-providers/wagon-http/

正如 keiki 在评论中指出的那样,3 似乎是默认值,因此不清楚设置此值有何帮助.请根据您的经验发表评论.

During downloading dependencies by maven, one of it fails due to network issues:

Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-failsafe-plugin/2.16/maven-failsafe-plugin-2.16.pom
Plugin org.apache.maven.plugins:maven-failsafe-plugin:2.16 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-failsafe-plugin:jar:2.16

I would like to retry it for n times where n will be configurable. How can I do this?

解决方案

I had a similar problem in Gitlab CI/CD. This seems to have resolved the issue:

-Dmaven.wagon.http.retryHandler.count=3

Since version 3.2, the retry handler can be configured with system properties:

...

    • maven.wagon.http.retryHandler.count = number of retries for default or standard implementations.

Other HTTP client settings are described here: https://maven.apache.org/wagon/wagon-providers/wagon-http/

Edit: As keiki pointed out in the comments, 3 appears to be the default, so it's not clear how setting this value would help. Please comment with your experience.

这篇关于如果失败,Maven 重试依赖项下载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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