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

Maven Assembly Plugin打包指定文件夹失败,求配置错误排查

Maven Assembly Plugin配置错误分析及修复

错误原因

你配置中的核心问题是同时使用了descriptorRefs的jar-with-dependencies描述符和自定义fileSets。jar-with-dependencies这个内置描述符的作用是打包项目编译后的类文件及所有依赖jar包,它的优先级会覆盖你自定义的fileSets规则,导致插件忽略了wso2mi文件夹的打包配置,最终只生成了包含Maven构建产物的压缩包。

修复方案

移除配置中的<descriptorRefs>节点,只保留自定义的fileSets配置,让插件专注于打包指定目录的内容:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-assembly-plugin</artifactId>
    <version>3.3.0</version>
    <executions>
        <execution>
            <id>create-zip</id>
            <phase>package</phase>
            <goals>
                <goal>single</goal>
            </goals>
            <configuration>
                <appendAssemblyId>false</appendAssemblyId>
                <finalName>wso2mi</finalName>
                <includeBaseDirectory>false</includeBaseDirectory>
                <formats>
                    <format>zip</format>
                </formats>
                <fileSets>
                    <fileSet>
                        <directory>${project.basedir}/wso2mi</directory>
                        <outputDirectory>/</outputDirectory>
                        <includes>
                            <include>**/*</include>
                        </includes>
                    </fileSet>
                </fileSets>
            </configuration>
        </execution>
    </executions>
</plugin>

验证方法

执行mvn clean package命令后,检查target目录下生成的wso2mi.zip,此时压缩包应包含wso2mi文件夹下的所有文件和子目录。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.24 13:45:17