Eclipse error setting up Maven project for class exercise: Check $M2_HOME environment variable and mvn script match

前端 未结 7 1158
忘掉有多难
忘掉有多难 2020-12-24 08:16

I have found a few related questions on this, but they\'re all related to Intellij or on Mac OS. I\'m on Windows 8.1 and using Eclipse:

Eclipse Java EE IDE f

相关标签:
7条回答
  • 2020-12-24 08:35

    I managed to work out a solution for this.

    1) I had to to to run configurations and add an argument to the VM. (Run - Run Configurations - JRE Tab - VM arguments). Enter the following in the text box

     -Dmaven.multiModuleProjectDirectory=%M2_HOME%
    

    You need to use %M2_HOME% or something similar to represent the path to Maven, because when I added my path to that argument directly, it was unable to find it. I think it's because there is a length limit on the argument. My path was

    C:\Program Files\Apache Software Foundation\apache-maven-3.3.1
    

    and I got an error stating that it couldn't find the runtime at Program Files\Apache

    2) Set up a system environment variable of called M2_HOME with C:\Program Files\Apache Software Foundation\apache-maven-3.3.1

    Control Panel - System and Security - System - Advanced System Settings - Environment Variables - System Variables - New

    0 讨论(0)
  • 2020-12-24 08:40

    Updating your m2eclipse installation from https://www.eclipse.org/m2e will solve this issue.

    0 讨论(0)
  • 2020-12-24 08:43

    adding below to VM argument worked for me -Dmaven.multiModuleProjectDirectory=M2_HOME

    0 讨论(0)
  • 2020-12-24 08:45

    Go to: Window--> Preference --> Java --> Installed JREs --> Edit In the edit Default VM arguments you need to put If you already set the maven home, for Windows machine:

    -Dmaven.multiModuleProjectDirectory=M2_HOME
    

    And for Linux and Mac OS X:

    -Dmaven.multiModuleProjectDirectory=$M2_HOME
    

    In case you are using Maven 3.x, the variable is named $MAVEN_HOME

    -Dmaven.multiModuleProjectDirectory=$MAVEN_HOME
    
    0 讨论(0)
  • 2020-12-24 08:51

    You're not alone in encountering this. I recently moved to 3.3.1 as well and am encountering this same problem.

    This isn't the best answer, but this will probably help you today. Try moving back to the latest 3.2.x. (Currently 3.2.5)

    I have a feeling it's related to MNG-5767 and a change that recently made it in. There may be some functionality in an m2e update or it may have something to do with the structure of your maven project. Without more detail, it's going to be difficult to tell.

    0 讨论(0)
  • 2020-12-24 08:54

    Access the following location in eclipse

    Window
      Preference
        Java
          Installed JREs
    

    Now edit Default VM arguments and place below arguments according to your OS type.

    If Windows,

    -Dmaven.multiModuleProjectDirectory=M2_HOME
    

    If Linux,

    -Dmaven.multiModuleProjectDirectory=$M2_HOME
    
    0 讨论(0)
提交回复
热议问题