使用 maven pom.xml 启动具有不同选项的相同 java 进程的两个实例

Starting two instances of same java process with different options using maven pom.xml

这就是我所拥有的,但无法正常工作。我永远看不到进程的第二个实例 运行。

<profile>
  <id>myid</id>
  <activation>
    <property>
      <name>myid</name>
    </property>
  </activation>
  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.3.2</version>
        <executions>
          <execution>
            <id>first-execution</id>
            <phase>integration-test</phase>
            <goals>
              <goal>exec</goal>
            </goals>
            <configuration>
              <executable>java</executable>
              <classpathScope>compile</classpathScope>
              <arguments>
                <argument>-Djava.net.preferIPv4Stack=true</argument>
                <argument>-Ddw.logging.file.currentLogFilename=${user.home}/logs/abc_20.log</argument>
                <argument>-Ddw.http.option1=5000</argument>
                <argument>-Ddw.http.option2=5001</argument>
                <argument>-Ddw.option3=abc1</argument>
                <argument>-Ddw.Id=abcdef1</argument>
                <argument>-classpath</argument>
                <classpath />
                <argument>com.mycompany.SomeService</argument>
                <argument>server</argument>
                <argument>dir1/config.yml</argument>
              </arguments>
            </configuration>
          </execution>
          <execution>
            <id>second-execution</id>
            <phase>deploy</phase>
            <goals>
              <goal>exec</goal>
            </goals>
            <configuration>
              <executable>java</executable>
              <classpathScope>compile</classpathScope>
              <arguments>
                <argument>-Djava.net.preferIPv4Stack=true</argument>
                <argument>-Ddw.logging.file.currentLogFilename=${user.home}/logs/abc_21.log</argument>
                <argument>-Ddw.http.option1=6000</argument>
                <argument>-Ddw.http.option2=6001</argument>
                <argument>-Ddw.option3=abc2</argument>
                <argument>-Ddw.Id=abcdef2</argument>
                <argument>-classpath</argument>
                <classpath />
                <argument>com.mycompany.SomeService</argument>
                <argument>server</argument>
                <argument>dir1/config.yml</argument>
              </arguments>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</profile>

任何 help/ideas/thoughts 将不胜感激。

要使用异步选项,您需要像这样配置插件:

<configuration>
  ...
  <async>true</async>
</configuration>

同时考虑阅读 https://maven.apache.org/guides/mini/guide-configuring-plugins.html#Configuring_Parameters 关于如何配置任何 maven 插件的内容。