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

如何执行mvn clean deploy时排除WAR包部署至制品仓库?

解决Maven Deploy阶段跳过特定WAR包部署的问题

你可以通过以下两种方式实现只跳过目标WAR包的部署,且不影响共用父POM下的其他应用:

方法一:在目标WAR模块单独配置跳过部署

直接在需要跳过部署的WAR模块的pom.xml中,为maven-deploy-plugin添加skip配置,仅对当前模块生效:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-deploy-plugin</artifactId>
            <version>3.1.1</version> <!-- 替换为你项目使用的插件版本 -->
            <configuration>
                <skip>true</skip>
            </configuration>
        </plugin>
    </plugins>
</build>

方法二:通过父POM属性控制灵活开关

如果需要更灵活的控制(比如后续可快速启用/禁用),可以在父POM中统一配置插件的跳过属性,再在目标模块中开启跳过:

  1. 在共用父POM的pluginManagement中定义插件配置:
<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-deploy-plugin</artifactId>
                <version>3.1.1</version>
                <configuration>
                    <skip>${deploy.skip}</skip>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>
</build>
  1. 在需要跳过部署的WAR模块的pom.xml中设置属性:
<properties>
    <deploy.skip>true</deploy.skip>
</properties>

其他未设置该属性的模块会默认使用deploy.skip=false,正常执行部署流程。

注意:maven-deploy-plugin本身没有提供直接按artifactId过滤部署的配置项,但通过上述两种子模块级别的配置,可以精准实现你的需求,不会影响父POM下的其他应用。

内容的提问来源于stack exchange,提问作者Marc Gil Sendra

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.25 22:17:10