[英]Run Netbeans maven project from command-line?
I've got a Maven project that runs perfectly inside Netbeans. 我有一个在Netbeans内完美运行的Maven项目。 How can I execute the application from the command-line (without Netbeans)?
如何从命令行执行应用程序(没有Netbeans)?
There's a plugin for that: http://www.mojohaus.org/exec-maven-plugin/ 有一个插件: http : //www.mojohaus.org/exec-maven-plugin/
$ mvn exec:java -Dexec.mainClass="com.mycompany.App"
Assuming com.mycompany.App
is you main class. 假设
com.mycompany.App
是你的主类。
Using the Maven Exec Plugin and its exec:java
goal as suggested is a first option. 使用Maven Exec插件及其
exec:java
建议的exec:java
目标是第一个选项。 And the command suggested is correct, you have to specify -Dexec.mainClass=VALUE
on the command line. 并且建议的命令是正确的,您必须在命令行上指定
-Dexec.mainClass=VALUE
。
mvn exec:java -Dexec.mainClass=com.acme.Hello
Regarding your "classpath problem", well, you didn't describe it very clearly. 关于你的“类路径问题”,你没有清楚地描述它。 What is your problem?
你有什么问题? What are your dependencies exactly?
你的依赖是什么? Just in case, there is a
classpathScope
parameter allowing to define the scope of the classpath passed to the plugin. 以防万一,有一个
classpathScope
参数允许定义传递给插件的类路径的范围。 Eg: 例如:
mvn exec:java -Dexec.classpathScope=compile -Dexec.mainClass=com.acme.Hello
As an alternative to the above plugin, there is MOP . 作为上述插件的替代品,有MOP 。 What is MOP?
什么是MOP?
What is MOP?
什么是MOP?
MOP is a small utility for executing Java programs which are stored as artifacts like jars or bundles in a Maven repository.
MOP是一个用于执行Java程序的小实用程序,它在Maven存储库中存储为诸如jar或bundle之类的工件。
MOP automatically deals with the following for you
MOP会自动为您处理以下事项
- transitive dependencies
传递依赖
- downloading artifacts from remote repositories and caching them locally
从远程存储库下载工件并在本地缓存它们
- setting up your classpath
设置类路径
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.