mvn command is not recognized as an internal or external command

前端 未结 22 2301
执念已碎
执念已碎 2020-12-30 19:20

I am getting the mvn command not recognized as an internal or external command.

I have setup the M2_HOME, JAVA_HOME and added %M2_HOME%/bin to the path

相关标签:
22条回答
  • 2020-12-30 19:50

    For Windows you need to do the following:

    1. Windows and type env

    2. Open the edit environment panel

    3. Click Environment Variables

    4. In the system variables section, double click Path

    5. In the dialog, create a System Variable under Path like below ->

      MVN_HOME: C:\Users<username>\Documents\Project\Software\apache-maven-3.6.3\bin

    6. Open a new command prompt and hit mvn, you should be able to now.

    0 讨论(0)
  • 2020-12-30 19:50

    You have written three paths above. The first path (path to maven) should be pointing to the bin directory.

    Path to Maven: C:\apache-maven-3.1.0\apache-maven-3.1.0\bin;

    Below are right. Above path should be corrected.

    M2_HOME:C:\apache-maven-3.1.0\apache-maven-3.1.0;

    PATH: Other things,C:\Program Files (x86)\Java\jdk1.7.0_40\bin,C:\apache-maven-3.1.0\apache-maven-3.1.0\bin;

    0 讨论(0)
  • 2020-12-30 19:51
    1. Try with echo %path% , if this option doesn't show your M2_HOME and others variable values as directory path, then create a new environment variable lets say PATH, and assign like below:

      PATH=%JAVA_HOME%\bin;%M2_HOME%\bin
      
    2. Add this in variable path=.....;%PATH%

    3. Now open a new cmd, and try to echo %path%
      it will show all thh system path

    Now you can check mvn -version it will solve the problem , if not try to restart the system

    P.S. as per doc, you should expend your zip distribution in C:\Program Files\Apache Software Foundation. But ideally it doen't matter

    0 讨论(0)
  • 2020-12-30 19:51

    One most important and often overlooked aspect is the %MAVEN_HOME%\bin or %M2_HOME%\bin should be the first thing in the %PATH% environment variable.

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