我使用执行以下代码mvn exec:java com.mycompany.FooServer.
我想添加另一个我可以执行的服务器mvn exec:java com.mycompany.BarServer.
我如何在一个pom文件中执行此操作?
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>com.mycompany.FooServer</mainClass>
</configuration>
</plugin>
</build>
Run Code Online (Sandbox Code Playgroud)
Tim*_*ien 86
试试这个.您可以在执行下执行多个执行.您需要做的就是在执行时移动配置元素.该插件具有配置,但每次执行也可以具有单独的配置元素.
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<id>first-execution</id>
<goals>
<goal>java</goal>
</goals>
<configuration>
<mainClass>com.mycompany.FooServer</mainClass>
</configuration>
</execution>
<execution>
<id>second-execution</id>
<goals>
<goal>java</goal>
</goals>
<configuration>
<mainClass>com.mycompany.BarServer</mainClass>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Run Code Online (Sandbox Code Playgroud)
使用Maven 3.3.1及更高版本,您可以使用其ID运行执行
mvn exec:java@id
Run Code Online (Sandbox Code Playgroud)
在这种情况下,命令将是mvn exec:java@first-execution和mvn exec:java@second-execution.有关详细信息,请参阅此答案.
dar*_*nto 10
@tieTYT:您可以使用两个不同的配置文件选择id执行:
mvn test -Pmanager
mvn test -Pproxy
<profiles>
<profile>
<id>proxy</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<mainClass>pt.inesc.proxy.Proxy</mainClass>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>manager</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<mainClass>pt.inesc.manager.Manager</mainClass>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
28121 次 |
| 最近记录: |