热在 Maven 中添加 war 依赖而不覆盖它

Hot to add a war dependency in maven without having it overlayed

我们正在开发一个 Java Web 应用程序,将在 Tomcat9 中作为 war 文件部署。

由于系统架构的原因,我们希望有一些其他 war 文件需要单独部署 war 文件。它们是商业广告,不受我控制。

我想在 pom 中添加这个单独的 wars 作为运行时,所以我们用来部署应用程序的 pom 知道它们是必需的,并且还会在 webapps 中部署任何 war 依赖项目录

我遇到的问题是,在我包含此 war 运行时依赖项的那一刻,打包阶段将它们作为覆盖添加到我们的 war 应用程序文件中。

我想要的是避免将此 war 文件作为叠加层添加到我们的 war 文件中。

我没有找到关于如何避免 Maven 行为的参考资料。

由于 NDA 限制,我无法共享真实的 pom 文件。这是我现在构建的不完整示例。

<?xml version="1.0" encoding="UTF-8"?>
<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>myOrg</groupId>
        <artifactId>myApp</artifactId>
        <version>1.0</version>
    </parent>

    <artifactId>myApp-war</artifactId>
    <packaging>war</packaging>
    <name>internal-app-war</name>
    <version>2.8</version>

    <dependencies>
        <dependency>
            <groupId>com.exampleorg</groupId>
            <artifactId>ExampleA</artifactId>
            <type>war</type>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>com.exampleorg</groupId>
            <artifactId>ExampleB</artifactId>
            <type>war</type>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            All jar dependencies with compile scope
        </dependency>
    </dependencies>
</project>

谁能提出实现该目标的方法?

提前致谢。

您在这里误用了 <dependencies>

如果你想确保其他 WAR 部署在同一台服务器上,那么你需要在 Maven 之外进行管理,例如使用 Puppet/Chef/... 或通过 docker 容器。

Maven 依赖项仅适用于构建本身。