1

Windows 7 无法将 mvn 识别为命令。

环境变量:

M2_HOME:  D:\apache-maven-3.0.4
M2:  %M2_HOME%\bin
PATH: . . . :M2_HOME;M2; . . .

在命令提示符下,输入“echo %M2_HOME%”和“echo %M2%”给出:

D:\apache-maven-3.0.4  and  D:\apache-maven-3.0.4\bin

输入 "%M2%\mvn --version" 给出:

Apache Maven 3.0.4 (r1232337; 2012-01-17 03:44:56-0500)
Maven Home: D:\apache-maven-3.0.4
Java Version: 1.7.0_03, vendor: Oracle Corporation
Java Home: D:\Glassfish3\jdk7\jre
and so on.

只需输入 mvn --version" 产生:

mvn is not recognized as an internal or external command,
operable program or file.

我已重新启动 Windows 7 无济于事。我不知道这里发生了什么。有什么建议么?

4

2 回答 2

4

您必须将 %M2% 添加到 Path 变量中

于 2012-05-21T15:32:54.533 回答
3

You need to set you PATH to refer to %M2% instead of just M2, otherwise the OS is looking for mvn in the folder M2, not the path denoted by the value of the M2 env. variable

于 2012-05-21T15:42:09.747 回答