mvn is not recognized after installation Maven 3

别来无恙 提交于 2019-12-19 10:02:11

问题


I have some problems with my maven 3 installation.

I have downloaded maven 3.0.3 and extracted it to a folder. I set the following environment variables.

  • M2_HOME:
    C:\a few folders\apache-maven-3.0.3
  • M2:
    %M2_HOME%\bin
  • JAVA_HOME:
    C:\Program Files\Java\jdk1.6.0_25
  • Path:
    %JAVA_HOME%\bin; %M2%

I get a message that the command is not recognized when i type "mvn" in the command line. Any ideas?


回答1:


Everything looks OK.

  • I don't know if there should be a space after the semicolon and %M2%. This might be your problem.
  • Make sure you typed a "a few folders" correctly.



回答2:


Maven 3.0.3 and later doesn't need the M2_HOME variable. The following environment variable changes are sufficient to run Maven from the command-line:

  1. Setting JAVA_HOME to the Java jdk directory (eg. C:\Program Files\Java\jdk1.6.0_29)
  2. Setting PATH to include the Maven bin directory.



回答3:


Try this:

Add(create) these new variables at the SYSTEM VARIABLES (M3_HOME and M3):

 M3_HOME: C:\maven_installation_folder\

 M3: %M3_HOME%\bin

Include at: "CLASSPATH" and "Path" variables

 CLASSPATH: other_variables;%M3%;

 Path: other_variables;%M3%;

Go to Command Prompt (cmd) and type:

 mvn -version



回答4:


Maven 3.0.3 and later doesn't need the M2_HOME variable. So no need to add that.

I did the following in the Windows System variables and it works:

JAVA_HOME=C:\Program Files\Java\jdk1.8.0_31
Path=C:\Program Files\Java\jdk1.8.0_31\bin;C:\Selenium 3\Maven\apache-maven-3.3.3\bin


来源:https://stackoverflow.com/questions/5755137/mvn-is-not-recognized-after-installation-maven-3

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!