java Maven 和 IntelliJ 的 `-Dmaven.multiModuleProjectDirectory not set` 问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29983683/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 16:14:05  来源:igfitidea点击:

`-Dmaven.multiModuleProjectDirectory not set` issue with Maven and IntelliJ

javamavenintellij-ideaintellij-13

提问by null

I've spent quite some time trying to figure out what I'm doing wrong and hoping someone may be able to help.

我花了很长时间试图弄清楚我做错了什么,并希望有人能够提供帮助。

My current setup is running Maven 3.3.3 (via homebrew) and Java 1.8. IntelliJ 13 is the IDE of choice.

我当前的设置正在运行 Maven 3.3.3(通过自制软件)和 Java 1.8。IntelliJ 13 是首选的 IDE。

Running mvn -versionresults in the following:

运行mvn -version结果如下:

Apache Maven 3.3.3 (7994120775791599e205a5524ec3e0dfe41d4a06; 2015-04-
22T12:57:37+01:00)
Maven home: /usr/local/Cellar/maven/3.3.3/libexec
Java version: 1.8.0_45, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.10.2", arch: "x86_64", family: "mac"

which I believe means everything is OK, but when I go to my IDE and try to run a Maven project I get this error:

我相信这意味着一切正常,但是当我转到我的 IDE 并尝试运行 Maven 项目时,我收到此错误:

/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/bin/java -Dmaven.home=/usr/local/Cellar/maven/3.3.3/libexec -Dclassworlds.conf=/usr/local/Cellar/maven/3.3.3/libexec/bin/m2.conf -Didea.launcher.port=7539 "-Didea.launcher.bin.path=/Applications/IntelliJ IDEA 13.app/bin" -Dfile.encoding=UTF-8 -classpath "/usr/local/Cellar/maven/3.3.3/libexec/boot/plexus-classworlds-2.5.2.jar:/Applications/IntelliJ IDEA 13.app/lib/idea_rt.jar" com.intellij.rt.execution.application.AppMain org.codehaus.classworlds.Launcher -Didea.version=13.1.3
-Dmaven.multiModuleProjectDirectory system propery is not set. Check $M2_HOME environment variable and mvn script match.
Process finished with exit code 1

My M2_HOME var is set to /usr/local/Cellar/maven/3.3.3/libexec, the same directory where homebrew installed it, and this also matches the IDE settings.

我的 M2_HOME 变量设置为/usr/local/Cellar/maven/3.3.3/libexec,与自制软件安装它的目录相同,这也与 IDE 设置匹配。

One search lead me to believe it may be something to do with Maven version and the IDE but I'm not convinced. Can someone please shed some light on this please?

一项搜索让我相信这可能与 Maven 版本和 IDE 有关,但我不相信。有人可以对此有所了解吗?

回答by Felix Seele

Just in case you have that error again go to Settings -> Maven -> Runnerand add

以防万一您再次遇到该错误,请转到Settings -> Maven -> Runner并添加

-Dmaven.multiModuleProjectDirectory=$M2_HOME

to VM Options.

到虚拟机选项。

enter image description here

在此处输入图片说明

回答by Ismail Kattakath

I had this wired issue while trying to build CAS Overlay Template using Maven. I could resolve it by adding the following environment variable:

我在尝试使用 Maven 构建 CAS 覆盖模板时遇到了这个有线问题。我可以通过添加以下环境变量来解决它:

MAVEN_OPTS = -Dmaven.multiModuleProjectDirectory

回答by Makoto

From the original question, the OP has solved their issue through this approach.

从最初的问题来看,OP 已经通过这种方法解决了他们的问题。

I upgraded to IDEA 14, imported settings, created a new Spring project and it worked out of the box.

我升级到 IDEA 14,导入设置,创建了一个新的 Spring 项目,它开箱即用。