Maven M2_HOME set to an invalid directory (Windows 7)

后端 未结 16 2315
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-06 00:59

I\'ve tried installing Maven to Windows 7 with poor results. Some basic info:

Maven installation directory: C:\\Program Files\\Apache Software Foundation\\ap

相关标签:
16条回答
  • 2020-12-06 01:22

    Add entire bin location to "PATH" environment variable Ex: C:\Program Files\Apache Software Foundation\apache-maven-3.0.4\bin

    No need of M2_HOME, M2.It worked for me

    Microsoft Windows [Version 10.0.14393] (c) 2016 Microsoft Corporation. All rights reserved.

    C:\Users\XXXX>mvn -version Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T22:11:47+05:30) Maven home: C:\Program Files\Apache Software Foundation\apache-maven-3.3.9\bin.. Java version: 1.8.0_91, vendor: Oracle Corporation Java home: C:\Program Files\Java\jdk1.8.0_91\jre Default locale: en_US, platform encoding: Cp1252 OS name: "windows 10", version: "10.0", arch: "amd64", family: "dos"

    0 讨论(0)
  • 2020-12-06 01:25

    Quick Answer
    Based on problems in using M2_HOME related to different Maven versions installed and to simplify things, the usage of M2_HOME has been removed and is not supported any more. Another important change for windows users: The usage of %HOME% has been replaced with %USERPROFILE%

    More detailed answer
    What you observed has always been a problem with maven. When you install two different versions in the same directory, the older version gets detected, while the newer one is not.
    After Maven 3.3.9 was released, the Eclipse Aether project was retired and the code base was migrated to the Apache Maven project. The original goal for the 3.4.0 release was to replace Aether with the exact same code after migration to the Apache Maven project and then proceed with bug fixes to the resolver code as well as other areas of Maven. This never quite happened as intended and the decision was taken to forever burn the 3.4.x release line. The switch to 3.5 brought with it these changes

    0 讨论(0)
  • 2020-12-06 01:26

    Get rid of the env variable M2_HOME. It is not used by maven 3, and in fact, confuses it. If you had used it in your path, then either define the path to maven bin explictly, or change it to something else - like M3_HOME.

    0 讨论(0)
  • 2020-12-06 01:28

    I've the same problem on my computer and I resolved it :

    • I deleted the Maven directory and the Maven environment variables
    • I downloaded the binary zip archive on https://maven.apache.org/download.cgi
    • I unzipped it on C:\maven
    • I added new environement variable : C:\maven in M2_HOME, %M2_HOME%\lib in M2 and %M2% added in PATH

    And it works !

    0 讨论(0)
提交回复
热议问题