[英]Running Maven goals in a reactor project without doing “mvn install”
I'm trying to execute a Java file in a subproject in a maven reactor project. 我正在尝试在maven reactor项目的子项目中执行Java文件。 This is similar to the question Maven exec:java goal on a multi-module project , but unless I do a
mvn install
then the exec plugin can't find the class that I'm trying to run in the subproject. 这类似于Maven exec的问题:多模块项目的java目标 ,但除非我进行
mvn install
,否则exec插件找不到我试图在子项目中运行的类。
Perhaps I misunderstand the intended workflow of mvn install
, but having to do mvn install every time I make changes really complicates the workflow. 也许我误解了
mvn install
的预期工作流程,但每次进行更改时都必须安装mvn才能使工作流程变得复杂。
When I execute the file from Eclipse, Eclipse sets up the classpath correctly (ie module1/target/classes
, module2/target/classes
) and I want to emulate this behaviour from the command line. 当我从Eclipse执行文件时,Eclipse正确设置了类路径(即
module1/target/classes
, module2/target/classes
),我想从命令行模拟这种行为。 I thought doing mvn -pl exec:java -Dexec.mainClass=...
would set up the classpath in this way, but the class is not found in this case. 我以为做
mvn -pl exec:java -Dexec.mainClass=...
会以这种方式设置类路径,但在这种情况下找不到类。
The classpath isn't the problem in that case. 在这种情况下,类路径不是问题。 But you have to compile your classes (eg at least run mvn compile).
但是你必须编译你的类(例如至少运行mvn compile)。 If you run your application within Eclipse, Eclipse will do the compile work, on the commandline you have to explicitly call that command.
如果在Eclipse中运行应用程序,Eclipse将执行编译工作,在命令行上必须显式调用该命令。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.