从 Tomcat 8 开始,Cargo 在后台

Starting Tomcat 8 with Cargo in background

我正在尝试 运行 使用 Cargo 和 Tomcat 8(安装模式)的 Web 应用程序。我将 Tomcat 作为 maven 的后台进程启动(默认情况下,cargo:run 阻止控制台,等待 Ctrl+C),所以我将 cargo.process.spawn 属性 设置为 true,但我得到以下输出:

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building webapp-launcher 0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- cargo-maven2-plugin:1.6.2:run (default-cli) @ webapp-launcher ---
[INFO] [en2.ContainerRunMojo] Resolved container artifact org.codehaus.cargo:cargo-core-container-tomcat:jar:1.6.2 for container tomcat8x
[INFO] [talledLocalContainer] Tomcat 8.x starting...
[INFO] [stalledLocalDeployer] Deploying [/home/tomcat/.m2/repository/<<****removed****>>/<<****removed****>>.war] to [/home/tomcat/<<****removed****>>/target/cargo/configurations/tomcat8x/webapps]...
[INFO] [talledLocalContainer] Tomcat 8.x started on port [8080]
[INFO] [talledLocalContainer] spawn does not allow attributes related to input, output, error, result
[INFO] [talledLocalContainer] spawn also does not allow timeout
[INFO] [talledLocalContainer] finally, spawn is not compatible with a nested I/O <redirector>
[INFO] Press Ctrl-C to stop the container...

我尝试将 timeout 设置为 0,但没有任何改变。

这是我用来部署网络应用程序的pom.xml:

<?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>

    <groupId>dummy.test</groupId>
    <artifactId>webapp-launcher</artifactId>
    <version>0.1-SNAPSHOT</version>
    <packaging>pom</packaging>

    <repositories>
        <repository>
            <id>nexus-snapshots-1</id>
            <name>Snaphots</name>
            <url>***********************removed***********************</url>
            <releases>
                <enabled>false</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>

        <repository>
            <id>nexus-releases-1</id>
            <name>Releases</name>
            <url>***********************removed***********************</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>

    <properties>
        <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
        <dependency>
            <groupId>***********************removed***********************</groupId>
            <artifactId>***********************removed***********************</artifactId>
            <version>***********************removed***********************</version>
            <type>war</type>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.cargo</groupId>
                <artifactId>cargo-maven2-plugin</artifactId>
                <version>1.6.2</version>
                <configuration>
                    <container>
                        <timeout>0</timeout>
                        <containerId>tomcat8x</containerId>
                        <artifactInstaller>
                            <groupId>org.apache.tomcat</groupId>
                            <artifactId>tomcat</artifactId>
                            <version>8.5.12</version>
                        </artifactInstaller>
                    </container>
                    <configuration>
                        <type>standalone</type>
                        <properties>
                            <cargo.process.spawn>true</cargo.process.spawn>
                        </properties>
                    </configuration>
                    <deployables>
                        <deployable>
                            <groupId>***********************removed***********************</groupId>
                            <artifactId>***********************removed***********************</artifactId>
                            <type>war</type>
                        </deployable>
                    </deployables>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

编辑:

我认为这是一个错误,因为 org.codehaus.cargo.container.spi.jvm.DefaultJvmLauncherFactory class 设置了很多与生成模式不兼容的硬编码参数(参见 this 行)。

它应该在 Cargo 版本 1.6.3 中修复。