在 Eclipse 中运行 Maven Exec 插件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6079253/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Running Maven Exec Plugin Inside Eclipse
提问by knpwrs
Using m2eclipse, what is the simplest way to use the Codehaus Mojo Exec Pluginto launch my project without leaving eclipse? So far on the pom plugins screen I have set up the org.codehuas.mojo plugin.
使用 m2eclipse,在不离开 eclipse 的情况下使用Codehaus Mojo Exec 插件启动我的项目的最简单方法是什么?到目前为止,在 pom 插件屏幕上,我已经设置了 org.codehuas.mojo 插件。
Specifically, I would like to execute the following from inside eclipse:
具体来说,我想从 eclipse 内部执行以下操作:
mvn exec:java -Dexec.mainClass=org.sonatype.mavenbook.weather.Main
回答by ilcavero
- go to Run menu -> run configurations
- you should see a "Maven Build" item on the list of the left, double click it to create a new configuration of that type
- name it as you want
- browse workspace to select the base directory of your project
- set exec:java as the goal, and exec.mainClass / yourClass as parameters.
- 转到运行菜单 -> 运行配置
- 您应该在左侧列表中看到一个“Maven Build”项目,双击它以创建该类型的新配置
- 随意命名
- 浏览工作区以选择项目的基本目录
- 将 exec:java 设置为目标,将 exec.mainClass / yourClass 设置为参数。
This is how it looks on my set-up:
这是它在我的设置中的样子:
PD: if you have set the mainClass argument on the pom.xml, then the parameter from the execution will be disregarded.
PD:如果你在 pom.xml 上设置了 mainClass 参数,那么执行的参数将被忽略。
回答by grin
In pom.xml set the target class:
在 pom.xml 中设置目标类:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
<configuration>
<mainClass>org.sonatype.mavenbook.weather.Main</mainClass>
</configuration>
</execution>
</executions>
Then go to "Run as.. " -> "Maven build..." -> Goals "exec:java"
然后转到“Run as..”->“Maven build...”->目标“exec:java”
回答by Suchitto Palit
There's slight mistake in the pom.xml entry given by @grin. The correct one should be as follows:
@grin 给出的 pom.xml 条目中存在轻微错误。正确的应该是这样的:
<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>org.sonatype.mavenbook.weather.Main</mainClass>
</configuration>
</plugin>
回答by Manish
go to Run menu -> run configurations you should see a "Maven Build" item on the list of the left, double click it to create a new configuration of that type name it as you want browse workspace to select the base directory of your project set exec:java as the goal, and exec.mainClass / yourClass as parameters.
转到运行菜单 -> 运行配置,您应该在左侧列表中看到一个“Maven Build”项,双击它以创建该类型的新配置,将其命名为您想要浏览工作区以选择项目的基本目录将 exec:java 设置为目标,将 exec.mainClass / yourClass 设置为参数。
it worked for me Thanks !
它对我有用 谢谢!