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

Maven打包报错:无法定位assembly descriptor.xml文件

解决maven-assembly-plugin找不到descriptor.xml的问题

检查插件配置的描述符路径

maven-assembly-plugin默认会从项目根目录的src/main/assembly下加载描述符文件,如果你把descriptor.xml放在了test-dir根目录,必须在pom.xml里指定正确的相对路径:

正确的pom.xml配置示例

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-assembly-plugin</artifactId>
    <version>3.6.0</version>
    <configuration>
        <descriptors>
            <!-- 指定项目根目录下的descriptor.xml -->
            <descriptor>./descriptor.xml</descriptor>
        </descriptors>
    </configuration>
    <executions>
        <execution>
            <id>make-assembly</id>
            <phase>package</phase>
            <goals>
                <goal>single</goal>
            </goals>
        </execution>
    </executions>
</plugin>

确认执行命令的工作目录

必须在test-dir根目录下执行mvn package命令,否则相对路径会基于当前命令行的工作目录计算,导致插件去错误的路径查找文件。

可选:调整描述符的存放位置

如果不想手动指定路径,可将descriptor.xml移到maven默认的src/main/assembly目录下,此时pom.xml里只需写<descriptor>descriptor.xml</descriptor>,插件会自动识别该路径。

排查文件名正确性

确保文件名是descriptor.xml,没有拼写错误(比如少写字母、大小写不一致——Windows下大小写不敏感,但跨平台打包建议统一小写)。


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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.02 06:22:03