简体   繁体   English

cmd找不到mvn命令

[英]cmd cannot find mvn command

I just installed Maven and added the \\bin directory of maven to my path variables.我刚刚安装了 Maven 并将 maven 的\\bin目录添加到我的路径变量中。 When I try to use the mvn command in the Command Prompt I just get a message:当我尝试在命令提示符中使用mvn命令时,我只收到一条消息:

mvn: command not found mvn:找不到命令

Everything else I found on here did not help yet.我在这里找到的所有其他东西都没有帮助。

Edit:编辑:

I used https://maven.apache.org/install.html to install maven.我使用https://maven.apache.org/install.html安装 maven。

SET PATH=%PATH%;C:\Program Files\Maven\apache-maven-3.5.0\bin\mvn.cmd
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC

You have included the file in the path: 您已将文件包括在路径中:

C:\Program Files\Maven\apache-maven-3.5.0\bin\mvn.cmd

That is not good. 这是不好的。 The PATH environment variable should only include a path to where files, like exe and cmd's can be found. PATH环境变量应仅包括可找到诸如exe和cmd的文件的路径。

Adapt your PATH to read like this: 修改您的PATH使其像这样读取:

C:\Program Files\Maven\apache-maven-3.5.0\bin

(so remove the \\mvn.cmd ). (因此,请删除\\mvn.cmd )。 Make sure to start a new command prompt to verify if your path settings are correct. 确保启动新的命令提示符,以验证您的路径设置是否正确。

See How can I set user environmental variables (such as PATH) from a non-administrator account on Windows 7 to find the correct Windows dialog to adapt the settings among many more . 请参阅如何在Windows 7上从非管理员帐户设置用户环境变量(例如PATH)以找到正确的Windows对话框,以在更多设置中调整设置。

Following this tutorial by mkyong , I was able to get this to work on Windows 10 (v10.0.15063): 遵循mkyong的本教程之后 ,我能够使它在Windows 10(v10.0.15063)上运行:

  1. Install JDK and setup JAVA_HOME system variable 安装JDK并设置JAVA_HOME系统变量

  2. Download Maven zip, extract it and setup M2_HOME and MAVEN_HOME system variables to point to root maven folder (without \\bin) 下载Maven zip,解压缩并设置M2_HOMEMAVEN_HOME系统变量以指向根maven文件夹(无\\ bin)

  3. Update PATH system variable to include %M2_HOME%\\bin (this is what will let you run "mvn" in Command Prompt). 更新PATH系统变量以包含%M2_HOME%\\bin%M2_HOME%\\bin您在命令提示符中运行“ mvn”的原因)。

  4. Open Command Prompt (cmd.exe) and execute mvn -version 打开命令提示符(cmd.exe)并执行mvn -version


You can download Maven (apache-maven-3.5.0-bin.zip) here , if you don't have it already. 如果尚未安装Maven(apache-maven-3.5.0-bin.zip),则可以在此处下载。

The Java SDK (jdk-8u144-windows-x64.exe) can be downloaded from Oracle here . 您可以在此处从Oracle下载Java SDK(jdk-8u144-windows-x64.exe)。

This is my working maven configuration on Windows 10. Was more cumbersome to configure on W10 than on WXP or W7. 这是我在Windows 10上正常工作的Maven配置。在W10上进行配置比在WXP或W7上更为繁琐。

在此处输入图片说明

I've faced the same problem.我遇到了同样的问题。 I installed Maven and added the \\bin directory of maven to my path variables in System Variables , so I can only use MAVEN commands using admin rights (run cmd in windows as administrator)我安装了 Maven 并将 maven 的 \\bin 目录添加到我在System Variables路径变量中,所以我只能使用管理员权限使用MAVEN命令(以管理员身份在 windows 中运行 cmd)

I solved this by creating all under User variables (including the PATH variable).我通过在User variables (包括 PATH 变量)下创建所有User variables来解决这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM