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

使用org.codehaus.plexus依赖构建Maven项目时缺失类报错求助

Maven构建缺失PlexusIoResourceCollection类错误解决

问题描述

项目依赖了以下org.codehaus.plexus系列组件:

  • plexus、plexus-archiver、plexus-classworlds
  • plexus-compiler、plexus-compiler-api、plexus-compiler-javac、plexus-compiler-manager、plexus-compilers
  • plexus-component-annotations、plexus-components、plexus-container-default、plexus-containers
  • plexus-interactivity-api、plexus-interpolation、plexus-io、plexus-utils

执行mvn clean install时触发构建错误:

Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:2.1:copy (copy-misc-runtime) on project MyServer: Execution copy-misc-runtime of goal org.apache.maven.plugins:maven-dependency-plugin:2.1:copy failed: A required class was missing while executing org.apache.maven.plugins:maven-dependency-plugin:2.1:copy: org/codehaus/plexus/components/io/resources/PlexusIoResourceCollection

已尝试删除本地.m2仓库,问题仍存在。环境信息:

  • Java版本:openjdk version "1.8.0_292"
  • Maven版本:Apache Maven 3.9.1
  • pom.xml中pluginManagement配置片段:
<pluginManagement>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.1</version>
            <dependencies>
                <dependency>
                    <groupId>org.codehaus.plexus</groupId>
                    <artifactId>plexus-archiver</artifactId>
                    <version>1.0-alpha-11</version>
                </dependency>
            </dependencies>
        </plugin>
    </plugins>
</pluginManagement>

解决方案

方案1:升级maven-dependency-plugin版本(推荐)

maven-dependency-plugin 2.1版本过于老旧,和Maven 3.9.1存在兼容性问题,且依赖的plexus组件版本滞后。建议升级到3.0.0及以上版本(比如3.6.0),升级后插件会自动管理兼容的plexus依赖,无需手动指定plexus-archiver:

<pluginManagement>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>3.6.0</version>
        </plugin>
    </plugins>
</pluginManagement>

方案2:手动添加plexus-io依赖(适配旧插件场景)

如果必须保留2.1版本插件,需手动添加plexus-io依赖到插件的依赖列表中——缺失的PlexusIoResourceCollection类属于plexus-io组件,旧版plexus-archiver未包含该类或依赖的plexus-io版本不足:

<pluginManagement>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.1</version>
            <dependencies>
                <dependency>
                    <groupId>org.codehaus.plexus</groupId>
                    <artifactId>plexus-archiver</artifactId>
                    <version>1.0-alpha-11</version>
                </dependency>
                <dependency>
                    <groupId>org.codehaus.plexus</groupId>
                    <artifactId>plexus-io</artifactId>
                    <version>1.0</version>
                </dependency>
            </dependencies>
        </plugin>
    </plugins>
</pluginManagement>

辅助验证

执行mvn dependency:tree查看插件的依赖树,确认plexus-io是否被正确引入,以及版本是否包含缺失的类。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.25 05:25:39