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

Maven surefire插件2.18依赖解析失败,本地POM解析错误求助

Maven构建错误:无法解析maven-surefire-plugin:2.18

错误详情

  • 无法解析插件org.apache.maven.plugins:maven-surefire-plugin:2.18或其依赖,读取插件构件描述符失败
  • 本地仓库中C:\Users\Oscar Ochoa.m2\repository\org\apache\maven\surefire\surefire\2.18\surefire-2.18.pom文件不可解析,第31行第10位存在结束标签与开始标签不匹配问题

项目POM文件内容

<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>
    <parent>
        <groupId>org.sonatype.oss</groupId>
        <artifactId>oss-parent</artifactId>
        <version>9</version>
    </parent>
    <groupId>net.md-5</groupId>
    <artifactId>specialsource-maven-plugin</artifactId>
    <version>1.2.4</version>
    <packaging>maven-plugin</packaging>
    <name>SpecialSourceMP</name>
    <scm>
        <connection>scm:git:git@github.com:agaricusb/SpecialSourceMP.git</connection>
        <developerConnection>scm:git:git@github.com:agaricusb/SpecialSourceMP.git</developerConnection>
        <url>git@github.com:agaricusb/SpecialSourceMP.git</url>
    </scm>
    <issueManagement>
        <system>GitHub</system>
        <url>https://github.com/agaricusb/SpecialSourceMP/issues</url>
    </issueManagement>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <mavenPluginVersion>3.5</mavenPluginVersion>
        <mavenVersion>3.0</mavenVersion>
    </properties>
    <dependencies>
        <dependency>
            <groupId>net.md-5</groupId>
            <artifactId>SpecialSource</artifactId>
            <version>1.11.0</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
        <!--  Maven  -->
        <dependency>
            <groupId>org.apache.maven</groupId>
            <artifactId>maven-plugin-api</artifactId>
            <version>${mavenVersion}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.maven</groupId>
            <artifactId>maven-model</artifactId>
            <version>${mavenVersion}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.maven</groupId>
            <artifactId>maven-core</artifactId>
            <version>${mavenVersion}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.maven</groupId>
            <artifactId>maven-compat</artifactId>
            <version>${mavenVersion}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.maven</groupId>
            <artifactId>maven-artifact</artifactId>
            <version>${mavenVersion}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.maven.plugin-tools</groupId>
            <artifactId>maven-plugin-annotations</artifactId>
            <version>${mavenPluginVersion}</version>
            <scope>provided</scope>
        </dependency>
        <!--  Plexus  -->
        <dependency>
            <groupId>org.codehaus.plexus</groupId>
            <artifactId>plexus-utils</artifactId>
            <version>3.0.5</version>
        </dependency>
        <dependency>
            <groupId>org.codehaus.plexus</groupId>
            <artifactId>plexus-digest</artifactId>
            <version>1.0</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-plugin-plugin</artifactId>
                <version>${mavenPluginVersion}</version>
                <configuration>
                    <skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
                </configuration>
                <executions>
                    <execution>
                        <id>mojo-descriptor</id>
                        <goals>
                            <goal>descriptor</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>io.github.zlika</groupId>
                <artifactId>reproducible-build-maven-plugin</artifactId>
                <version>0.8</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>strip-jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

解决方法

  • 删除损坏的本地POM文件:找到路径C:\Users\Oscar Ochoa.m2\repository\org\apache\maven\surefire\surefire\2.18,删除其中的surefire-2.18.pom及相关缓存文件,重新执行Maven构建,Maven会自动下载正确的POM文件
  • 强制更新依赖:执行命令 mvn clean install -U,强制Maven更新所有依赖,包括损坏的插件构件
  • 显式指定插件版本:如果自动下载仍有问题,可在项目POM的<build><plugins>中添加maven-surefire-plugin的稳定版本配置,示例:
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.22.2</version>
</plugin>

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.18 04:05:14