如何在 Eclipse 中使用 Maven exec 插件?
How to use Maven exec plugin in Eclipse?
我是 Maven 的新手,我正在尝试 运行 使用 exec:java
的项目。我的构建失败了,大概是因为我没有 exec 插件。我下载了插件 (http://mvnrepository.com/artifact/org.codehaus.mojo/exec-maven-plugin),但现在我不知道如何使用它才能在 Eclipse 中使用它。我尝试将它添加到构建路径中,但这似乎不起作用。这可能是一个非常愚蠢的问题,但我如何让插件工作?
这是我的构建输出:
[INFO] Scanning for projects...
[INFO]
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Twitter2 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- exec-maven-plugin:1.4.0:java (default-cli) @ Twitter2 ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.826 s
[INFO] Finished at: 2015-06-11T14:24:29-06:00
[INFO] Final Memory: 10M/114M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.4.0:java (default-cli) on project Twitter2: The parameters 'mainClass' for goal org.codehaus.mojo:exec-maven-plugin:1.4.0:java are missing or invalid -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginParameterException
如错误所述,似乎 mainClass
参数未正确设置,该参数告诉插件 class 到 运行 的内容。有关插件的 java
目标的用法,请参阅 http://www.mojohaus.org/exec-maven-plugin/java-mojo.html。尝试在 POM 配置中添加参数:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<configuration>
<mainClass>fully.qualified.class.name</mainClass>
</configuration>
</plugin>
或在命令行中通过 属性 -Dexec.mainClass=fullClassName
。
我是 Maven 的新手,我正在尝试 运行 使用 exec:java
的项目。我的构建失败了,大概是因为我没有 exec 插件。我下载了插件 (http://mvnrepository.com/artifact/org.codehaus.mojo/exec-maven-plugin),但现在我不知道如何使用它才能在 Eclipse 中使用它。我尝试将它添加到构建路径中,但这似乎不起作用。这可能是一个非常愚蠢的问题,但我如何让插件工作?
这是我的构建输出:
[INFO] Scanning for projects...
[INFO]
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Twitter2 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- exec-maven-plugin:1.4.0:java (default-cli) @ Twitter2 ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.826 s
[INFO] Finished at: 2015-06-11T14:24:29-06:00
[INFO] Final Memory: 10M/114M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.4.0:java (default-cli) on project Twitter2: The parameters 'mainClass' for goal org.codehaus.mojo:exec-maven-plugin:1.4.0:java are missing or invalid -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginParameterException
如错误所述,似乎 mainClass
参数未正确设置,该参数告诉插件 class 到 运行 的内容。有关插件的 java
目标的用法,请参阅 http://www.mojohaus.org/exec-maven-plugin/java-mojo.html。尝试在 POM 配置中添加参数:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<configuration>
<mainClass>fully.qualified.class.name</mainClass>
</configuration>
</plugin>
或在命令行中通过 属性 -Dexec.mainClass=fullClassName
。