【发布时间】:2015-12-27 09:20:22
【问题描述】:
我正在将我的 Ant 项目转换为 Maven 项目。
在 Ant 中,我使用 Ant 中的 fork="yes" 选项在不同的线程中调用 Java 类。
现在我正在尝试在 Maven 中找到类似的任务。
我有如下代码,但我不确定它是否正确。它按预期调用我的主类,但它在同一个线程/JVM 中运行。
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>com.App</mainClass>
<arguments>
<argument>-s src/main/resources</argument>
</arguments>
</configuration>
</plugin>
这里的 com.App 是一个有 main 方法的类。
我需要在不同的线程中运行它,因为 App.main() 方法包含对 system.exit() 的调用,因此控件不会返回。由于我无权更改 App 类,因此我必须在不同的线程中调用它。
【问题讨论】:
-
请使用最新版本的 exec-maven-plugin (1.4)...
标签: java multithreading maven ant