未设置 Maven3.3.1 ECLIPSE:-Dmaven.multiModuleProjectDirectory 系统属性

我刚刚在 Mac OS X 上安装了 Maven 3.3.1,用 Eclipse 构建 Maven 项目时出现了以下错误:

-Dmaven.multiModuleProjectDirectory system property is not set.
Check $M2_HOME environment variable and mvn script match.

这在 Maven 3.2.5之前从未发生过。

有没有办法解决这个问题(除了降级到3.2.5) ?

在 Eclipse 中,我究竟可以在哪里设置这个“ multiModuleProjectDirectory”属性?

86623 次浏览

Define like this in the JVM options:

-Dmaven.multiModuleProjectDirectory=HOME_PATH_OF_YOU_PROJECT

In Eclipse you need to go like this.

Window-> Preference -> Java -> Installed JREs -> Edit

In the edit Default VM arguments you need to put

If you already set the maven home.

-Dmaven.multiModuleProjectDirectory=$M2_HOME

go to run configuration, create new maven build launch configuration where in the first tab you fill the base directory and the goal, then, go to jre tab and add to the vm args this config:

-Dmaven.multiModuleProjectDirectory=%M2_HOME%

where M2_HOME is an environment variable pointing to the base directory of your maven installation

This was filed as a bug with m2e in Eclipse at https://bugs.eclipse.org/bugs/show_bug.cgi?id=462944 , due to the changes in Maven 3.3.1.

This is fixed in m2e 1.5.2 as of 2015-04-13. This is an available release that can be installed from http://download.eclipse.org/technology/m2e/releases/ .

(No more changing JVM arguments for the entire workspace or for specific launch configurations required.)

If you want to try a second way, you can try to download a path from http://download.eclipse.org/technology/m2e/milestones/1.5/.

Open Help>install new software and download from url above. This way solved my problem.

In IntelliJ you can set this option in VM Options field that you can find in the next configuration view:

Preferences/Build, execution, deployment/Build tools/Maven/Runner

enter image description here

I encountered the same issue with Maven 3.3 and 3.2 versions, so I decided to downgrade it to version 3.0.5 and it worked just fine.

i had the same problem with intelliJ 14, i tried out different solutions provided at forums but not worked out. What i did is i completely uninstall intellij and installed intellij 15.0.1 and import the same project then all works fine.

In case you have this error message on your commandline, please verify if your PATH variable points to the same maven installation apache-maven-3.X.X/bin folder as your M2_HOME variable. In my case I was mixing up two versions which resulted in this error.

To set the maven.multiModuleProjectDirectory property permanently in Maven, I've added a default activated profile which initializes the property with the MAVEN_HOME environment variable in the settings.xml file. Or you could also alternatively use the M2_HOME environment variable.

<profile>
<id>my-profile</id>
<properties>
<maven.multiModuleProjectDirectory>${env.MAVEN_HOME}</maven.multiModuleProjectDirectory>
</properties>
</profile>
<activeProfiles>
<activeProfile>my-profile</activeProfile>
</activeProfiles>