[INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 06:18 min [INFO] Finished at: 2025-03-25T09:23:29+08:00 [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:3.2.3:war (default-war) on project oaservice: Execution default-war of goal org.apache.maven.plugins:maven-war-plugin:3.2.3:war failed: Plugin org.apache.maven.plugins:maven-war-plugin:3.2.3 or one of its dependencies could not be resolved: [ERROR] Could not transfer artifact org.codehaus.plexus:plexus-archiver:jar:4.1.0 from/to central (https://repo.maven.apache.org/maven2): Connect to repo.maven.apache.org:443 [repo.maven.apache.org/146.75.112.215] failed: connect timed out [ERROR] [ERROR] -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException
时间: 2025-04-12 11:25:40 浏览: 32
<think>嗯,用户遇到了Maven构建失败的问题,具体是maven-war-plugin 3.2.3依赖的plexus-archiver 4.1.0下载失败,连接超时。首先,我需要确认这个问题的常见原因和解决方案。
首先,应该检查网络连接是否正常。用户可能处于网络受限的环境,或者公司防火墙阻止了对Maven中央仓库的访问。这时候,可以尝试ping repo.maven.apache.org,看看是否能通。如果不行,可能需要配置代理或者在Maven的settings.xml中设置镜像仓库。
接下来,考虑依赖是否真的存在于中央仓库。有时候版本号可能拼写错误,或者该版本已被移除。可以手动访问https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-archiver/4.1.0/,确认plexus-archiver 4.1.0是否存在。如果不存在,可能需要升级到更高版本。
另外,清理本地仓库的缓存也是一个常用方法。删除本地.m2仓库中对应的plexus-archiver目录,让Maven重新下载依赖,有时候可以解决部分问题。
如果中央仓库访问不稳定,可以尝试更换为国内镜像源,比如阿里云的镜像。在settings.xml中添加镜像配置,替换中央仓库的URL为阿里云的地址,可能会加快下载速度并避免连接超时。
如果这些方法都不奏效,可能需要手动下载依赖并安装到本地仓库。使用mvn install:install-file命令将下载好的jar包安装到本地,这样Maven在构建时就可以找到它了。
另外,检查是否有插件配置指定了特定的仓库。有些项目的pom.xml可能配置了私服,如果私服不可达,也会导致下载失败。可以尝试注释掉这些仓库配置,使用默认的中央仓库或镜像。
最后,如果所有方法都失败,可能需要升级maven-war-plugin到更新的版本,因为新版本可能不再依赖有问题的plexus-archiver版本,或者依赖的版本已经修复了下载问题。查看Maven中央仓库中maven-war-plugin的最新版本,并修改pom.xml中的版本号,然后重新构建。
需要确保用户按照步骤逐一尝试,并提供具体的命令和配置示例,比如如何设置镜像,如何清理缓存,如何手动安装依赖等。同时,注意引用相关的参考资料,比如之前提到的yum安装的例子,但在这个场景中可能不太相关,所以引用可能需要调整。不过用户提供的引用可能是一个例子,实际回答中可能不需要包含不相关的引用。</think>针对Maven构建时maven-war-plugin依赖下载超时问题,以下是分步解决方案:
### 1. 验证基础网络连接
```bash
ping repo.maven.apache.org
telnet repo.maven.apache.org 443
```
若出现超时,需配置代理:
```xml
<!-- settings.xml -->
<proxies>
<proxy>
<id>myproxy</id>
<active>true</active>
<protocol>http</protocol>
<host>proxy.example.com</host>
<port>8080</port>
</proxy>
</proxies>
```
### 2. 强制更新依赖
```bash
mvn clean install -U -Dmaven.wagon.http.retryHandler.count=3
```
`-U`参数强制更新快照,重试次数设为3次[^1]
### 3. 镜像仓库配置(推荐阿里云)
```xml
<!-- settings.xml -->
<mirror>
<id>aliyunmaven</id>
<mirrorOf>central</mirrorOf>
<name>阿里云公共仓库</name>
<url>https://maven.aliyun.com/repository/public</url>
</mirror>
```
### 4. 手动安装依赖
若持续失败,手动操作:
```bash
wget https://repo1.maven.org/maven2/org/codehaus/plexus/plexus-archiver/4.1.0/plexus-archiver-4.1.0.jar
mvn install:install-file -Dfile=plexus-archiver-4.1.0.jar -DgroupId=org.codehaus.plexus -DartifactId=plexus-archiver -Dversion=4.1.0 -Dpackaging=jar
```
### 5. 插件版本升级
修改pom.xml升级插件:
```xml
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.2</version> <!-- 最新稳定版 -->
</plugin>
```
阅读全文
相关推荐









