【问题标题】:Running 2 webapps with maven Cargo?使用 maven Cargo 运行 2 个 Web 应用程序?
【发布时间】:2022-01-13 07:30:08
【问题描述】:

在执行我的测试场景之前,我需要在预集成阶段运行 2 个应用程序(作为 WAR 文件)。 我已经像这样配置了 maven cargo 插件:

<plugin>
                <groupId>org.codehaus.cargo</groupId>
                <artifactId>cargo-maven3-plugin</artifactId>
                <version>1.9.8</version>
                <executions>
                    <execution>
                        <id>neo-start-lanceur</id>
                        <phase>pre-integration-test</phase>
                        <configuration>
                            <container>
                                <containerId>tomcat8x</containerId>
                                <artifactInstaller>
                                    <groupId>org.apache.tomcat</groupId>
                                    <artifactId>tomcat</artifactId>
                                    <version>8.5.9</version>
                                </artifactInstaller>
                            </container>
                            <configuration>
                                <properties>
                                    <cargo.servlet.port>8081</cargo.servlet.port>
                                    <spring.profiles.active>tdc</spring.profiles.active>
                                    <JAVA_OPTS>-Xms512m -Xmx1536m -XX:MinHeapFreeRatio=20 -XX:MaxHeapFreeRatio=70</JAVA_OPTS>
                                </properties>
                                <home>${project.build.directory}/neo-lanceur</home>
                            </configuration>
                            <deployables>
                                <deployable>
                                    <groupId>fr.cnp.neo</groupId>
                                    <artifactId>neo-web-lanceur</artifactId>
                                    <type>war</type>
                                </deployable>
                            </deployables>
                        </configuration>
                        <goals>
                            <goal>start</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>neo-stop-lanceur</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>stop</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>neo-start-webapp</id>
                        <phase>pre-integration-test</phase>
                        <configuration>
                            <container>
                                <containerId>tomcat8x</containerId>
                                <artifactInstaller>
                                    <groupId>org.apache.tomcat</groupId>
                                    <artifactId>tomcat8</artifactId>
                                    <version>8.5.9</version>
                                </artifactInstaller>
                            </container>
                            <configuration>
                                <properties>
                                    <cargo.servlet.port>8080</cargo.servlet.port>
                                    <spring.profiles.active>tdc</spring.profiles.active>-->
                                    <JAVA_OPTS>-Xms512m -Xmx1536m -XX:MinHeapFreeRatio=20 -XX:MaxHeapFreeRatio=70</JAVA_OPTS>
                                </properties>
                                <home>${project.build.directory}/neo-webapp</home>
                                <configfiles>
                                    <configfile>
                                        <file>${project.basedir}/../web/src/test/conf/neo.properties</file>
                                        <todir>webapps/neo-web/WEB-INF</todir>
                                    </configfile>
                                </configfiles>
                            </configuration>
                            <deployables>
                                <deployable>
                                    <groupId>fr.cnp.neo</groupId>
                                    <artifactId>neo-web</artifactId>
                                    <type>war</type>
                                </deployable>
                            </deployables>
                        </configuration>
                        <goals>
                            <goal>start</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>neo-stop-webapp</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>stop</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

但它只部署和运行第一个应用程序。

是否可以在单个 tomcat 实例上部署 2 个 WAR 或创建 2 个本地容器?

感谢您的帮助!!

【问题讨论】:

    标签: maven maven-cargo


    【解决方案1】:

    您可以将两个 WAR 部署在单个 Tomcat 实例上,方法是将它们放入 &lt;deployables&gt; 部分:

    
                                <deployables>
                                    <deployable>
                                        <groupId>fr.cnp.neo</groupId>
                                        <artifactId>neo-web-lanceur</artifactId>
                                        <type>war</type>
                                    </deployable>
                                    <deployable>
                                        <groupId>fr.cnp.neo</groupId>
                                        <artifactId>neo-web</artifactId>
                                        <type>war</type>
                                    </deployable>
                                </deployables>
    

    【讨论】:

    • 太棒了!它工作正常!但是我现在遇到了应用程序上下文名称必须不同的问题。
    • 应用程序上下文名称应该从工件 id 派生,至少根据 [1] 您可以明确指定作为可部署的一部分:some-application-context [1] codehaus-cargo.github.io/cargo/…
    猜你喜欢
    • 2013-02-20
    • 1970-01-01
    • 2014-12-23
    • 2017-03-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-21
    相关资源
    最近更新 更多