windows Maven:未找到 mvn 命令

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10649707/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 09:31:22  来源:igfitidea点击:

Maven: mvn command not found

windowsmaven

提问by Roaz

I set the following system veriables (OS = Vista):

我设置了以下系统验证(OS = Vista):

M2_HOME = C:\Program Files\Maven 
M2 = %M2_HOME%\bin 
path = %M2% 

If i run mvn -- version I get:

如果我运行 mvn -- 版本我得到:

mvn: command not found

Anyone have any idea why this could be? Thanks.

任何人都知道为什么会这样?谢谢。

采纳答案by khmarbaise

If you are on windows, what i suppose you need to do set the PATH like this:

如果您在 Windows 上,我想您需要像这样设置 PATH:

SET PATH=%M2%

furthermore i assume you need to set your path to something like C:...\apache-maven-3.0.3\ cause this is the default folder for the windows archive. On the other i assume you need to add the path of maven to your and not set it to only maven so you setting should look like this:

此外,我假设您需要将路径设置为 C:...\apache-maven-3.0.3\ 之类的内容,因为这是 Windows 存档的默认文件夹。另一方面,我假设您需要将 maven 的路径添加到您的而不是将其设置为仅 maven,因此您的设置应如下所示:

SET PATH=%PATH%;%M2%

回答by Howard Lee

I tried solutions from other threads. Adding M2 and M2_HOME at System variables, and even at User variables. Running cmd as admin. None of the methods worked.

我尝试了其他线程的解决方案。在系统变量甚至用户变量中添加 M2 和 M2_HOME。以管理员身份运行 cmd。没有一种方法奏效。

But today I added entire path to maven bin to my System variables "PATH" (C:\Program Files (x86)\Apache Software Foundation\apache-maven-3.1.0\bin) besides other paths, and so far it's working good. Hopefully it'll stay that way.

但是今天我将 maven bin 的整个路径添加到我的系统变量“PATH”(C:\Program Files (x86)\Apache Software Foundation\apache-maven-3.1.0\bin)除了其他路径之外,到目前为止它运行良好. 希望它会一直这样。

回答by emdhie

I followed this tutorial: How to install Maven on Windows

我遵循了本教程:如何在 Windows 上安装 Maven

But running mvn -version, I still got:

但是运行mvn -version,我仍然得到:

mvn: command not found

mvn:找不到命令

So, I closed the current git window, and opened a new one. Everything went okay :)

所以,我关闭了当前的 git 窗口,并打开了一个新窗口。一切顺利:)

回答by Vineeth Vinnu

mvn -version

mvn -version

export PATH=$PATH:/opt/apache-maven-3.6.0/bin

导出 PATH=$PATH:/opt/apache-maven-3.6.0/bin

回答by Abdur Rahman

Maven setup:

Maven设置:

a. install maven from https://maven.apache.org/download.cgi

一种。从https://maven.apache.org/download.cgi安装 maven

b. unzip maven and keep in C drive.

湾 解压maven并保存在C盘。

c. Set MAVEN_HOMEin system variable. enter image description here

C。在系统变量中设置MAVEN_HOME在此处输入图片说明

d. Set path for mavenenter image description here

d. 为maven设置路径在此处输入图片说明

回答by Thiago Bomfim

I think the tutorial passed by @emdhie will help a lot. How install maven

我认为@emdhie 通过的教程会有很大帮助。 怎么安装maven

But, i followed and still getting mvn: command not found

但是,我跟随并且仍然得到 mvn: command not found

I found this solution to know what was wrong in my configuration:

我找到了这个解决方案来了解我的配置出了什么问题:

I opened the command line and called this command:

我打开命令行并调用了这个命令:

../apache-maven-3.5.3/bin/mvn --version

After that i got the correct JAVA_HOME and saw that my JAVA_HOME was wrong.

之后我得到了正确的 JAVA_HOME 并看到我的 JAVA_HOME 是错误的。

Hope this helps.

希望这可以帮助。

回答by noni_methadoni

I think the problem is with the spaces. I had my variable at the System variables but it didn't work. When I changed variable Progra~1 = 'Program Files'everything works fine.

我认为问题出在空格上。我在系统变量中有我的变量,但它不起作用。当我更改变量时,Progra~1 = 'Program Files'一切正常。

M2_HOME C:\Progra~1\Maven\apache-maven-3.1.1

I also moved my M2_HOMEat the end of the PATH(%M2_HOME%\bin)I'm not sure if this has any difference.

我也在最后移动M2_HOMEPATH(%M2_HOME%\bin)我的我不确定这是否有任何区别。

回答by Maniganda Prakash

  1. Run 'path' in command prompt and ensure that the maven installation directory is listed.
  2. Ensure the maven is installed in 'C:\Program Files\Maven'.
  1. 在命令提示符下运行“ path”并确保列出了 maven 安装目录。
  2. 确保 maven 安装在“C:\Program Files\Maven”中。