You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Maven项目pom.xml报错:插件生命周期未覆盖及依赖解析失败

Maven依赖解析及生命周期配置报错问题

报错详情

  • 报错位置:pom.xml第4行xsi:schemaLocation末尾
  • 错误信息:
    1. 生命周期配置未覆盖插件执行:org.apache.maven.plugins:maven-compiler-plugin:3.13.0:compile及testCompile相关报错
    2. 核心异常:无法解析maven-compiler-plugin:3.13.0或其依赖,提示从google-maven仓库传输失败,缓存未过期
  • 尝试操作:执行mvn clean install后,出现maven-clean-plugin依赖解析失败的类似报错,网络其他操作正常,不确定是否为网络问题

项目pom.xml内容

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.example</groupId>
    <artifactId>demotest</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
    </properties> 
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>3.3.1</version> 
            </plugin>
        </plugins>
    </build>

</project>

mvn clean install终端输出

[INFO] Scanning for projects...
[INFO] 
[INFO] ------------------------< com.example:demotest >------------------------
[INFO] Building demotest 1.0-SNAPSHOT
[INFO]   from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
Downloading from google-maven: https://maven-central.storage-download.googleapis.com/repos/central/data/org/apache/maven/plugins/maven-clean-plugin/3.2.0/maven-clean-plugin-3.2.0.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.641 s
[INFO] Finished at: 2025-04-22T12:06:55-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Plugin org.apache.maven.plugins:maven-clean-plugin:3.2.0 or one of its dependencies could not be resolved:
[ERROR]         The following artifacts could not be resolved: org.apache.maven.plugins:maven-clean-plugin:pom:3.2.0 (absent): Could not transfer artifact org.apache.maven.plugins:maven-clean-plugin:pom:3.2.0 from/to google-maven (https://maven-central.storage-download.googleapis.com/repos/central/data/): Broken pipe
[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

解决方案

1. 强制清理缓存并重新构建

执行以下命令,强制Maven更新依赖缓存,绕过未过期的本地缓存:

mvn clean install -U

2. 更换Maven仓库源

google-maven仓库连接不稳定,建议切换到国内镜像源(如阿里云):
找到Maven安装目录下的conf/settings.xml,或用户目录下的.m2/settings.xml,修改<mirrors>节点:

<mirrors>
    <mirror>
        <id>aliyunmaven</id>
        <mirrorOf>central</mirrorOf>
        <url>https://maven.aliyun.com/repository/public</url>
    </mirror>
</mirrors>

3. 明确绑定编译器插件生命周期

在pom.xml的<build><plugins>中添加maven-compiler-plugin的显式配置,解决生命周期未覆盖的问题:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>3.3.1</version> 
        </plugin>
        <!-- 添加编译器插件配置 -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.13.0</version>
            <configuration>
                <source>17</source>
                <target>17</target>
            </configuration>
        </plugin>
    </plugins>
</build>

4. 检查代理设置

如果使用网络代理,确认Maven的代理配置正确,或暂时关闭代理后尝试构建。

内容的提问来源于stack exchange,提问作者kareen Gresseau

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.13 07:31:13