mvn command is not recognized as an internal or external command

前端 未结 22 2298
执念已碎
执念已碎 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:27

    Restart your machine, after setting up your M2_HOME (pointing to you Maven basedir, NOT the bin dir) and PATH (PATH=%M2_HOME%\bin;%PATH%).

    Then do:

    dir %M2_HOME%\bin\mvn*
    

    If there is a .bat file, it should work under Windows, as it appears to be finding it. If there isn't one, then your paths are not right and you need to make sure your %PATH% variable really points to the correct path to Maven.

    Make sure you are using the proper slashes for your OS. Under Windows they're \.

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

    I had this same error but my problem was I had the following:

    M2_HOME = C:\Program Files (x86)\Apache Software Foundation\apache-maven-2.2.1;

    Which meant my PATH = %M2_HOME%\bin; (etc)

    ...became C:\Program Files (x86)\Apache Software Foundation\apache-maven-2.2.1;\bin

    i.e. a semicolon was where it shouldn't be.

    Which I discovered because Michael Ferry suggested using 'ECHO %PATH%' to see what the actual PATH output was.

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

    Try setting the path of maven first through command prompt.

    setpath.bat Open the cmd from the base window of the batch file.

    The rest maven commands can be used once path is set through cmd.

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

    Windows 10 -

    1. Add new variable "M2_HOME" -

    1. Update variable "path" -

    2. Verify on cmd -

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

    Write the entire maven path into the Environment PATH variable.

    Example:

    C:\Program Files\apache-maven-3.2.3\bin;
    

    My PATH variable wasn't reading %M2% or %M2_HOME%\bin properly, and therefore I wrote the full path into the PATH variable.

    Working.

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

    I faced similar problems. The article that helped me solve similar issues is by MKyong and is here: ****https://www.mkyong.com/maven/how-to-install-maven-in-windows/**** It is very important to include in maven's path the file that contains the 'bin','boot', 'conf', 'lib' etc. file folders. For example, in my case, the correct path is: C:\Program Files\Apache Software Foundation\maven\apache-maven-3.5.0-bin\apache-maven-3.5.0

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