使用maven pom.xml使用不同的选项启动同一Java进程的两个实例

时间:2018-12-22 04:19:32

标签: java maven intellij-idea build 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>

任何帮助/想法/想法将不胜感激。

1 个答案:

答案 0 :(得分:1)

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

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

还可以考虑阅读https://maven.apache.org/guides/mini/guide-configuring-plugins.html#Configuring_Parameters,了解如何配置任何Maven插件。