简体   繁体   English

在没有执行“mvn install”的情况下在reactor项目中运行Maven目标

[英]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/classesmodule2/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.

相关问题 执行 mvn clean install 时未运行测试用例,但项目编译成功 - Test cases are not running when doing a mvn clean install but the project is compiling success 运行 mvn install/mvn test 时出现 Maven mapstruct 问题 - Maven mapstruct issue when running mvn install/mvn test 在机器上未安装Maven可执行文件的情况下从Java运行Maven目标 - Running maven goals from Java without a Maven executable installed on the machine 通过更改 pom.xml 中的目标在 Maven 项目中运行 2 个功能文件 - Running 2 feature files in a Maven project by changing goals in pom.xml 在没有 mvn install:install-file 的情况下添加 maven 本地依赖项 - Adding maven local dependecies without mvn install:install-file Maven目标未在Eclipse Indigo上运行 - Maven Goals not running on Eclipse Indigo 在没有反应堆的情况下按顺序清理/安装多个Maven项目 - Clean/Install Multiple maven projects in order without reactor 运行mvn全新安装时出现Maven错误? - Getting maven error while running mvn clean install? eclipse中的Maven错误以及运行mvn clean install时的错误 - Maven errors in eclipse and while running mvn clean install 使用 maven-assembly-plugin 创建的 Jar 未使用 mvn install 运行 - Jar created using maven-assembly-plugin not running with mvn install
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM