mvn在cmd提示符下工作,但不在批处理中

时间:2018-03-27 13:53:01

标签: windows maven batch-file command-line

我正在尝试在批处理脚本中使用mvn,并且在运行脚本时遇到以下错误:

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

但是,当我在命令提示符下使用mvn clean install时,我可以从同一目录运行mvn。

有关系统环境变量的信息:

D:\Projects>echo %JAVA_HOME%
c:\Program Files\Java\jdk1.8.0_60
D:\Projects>echo %M2%
C:\Apps\apache-maven-3.3.3\bin
D:\Projects>echo %M2_HOME%
C:\Apps\apache-maven-3.3.3

路径:

C:\app\212482926\product\11.2.0\dbhome_1\bin;%GRADLE_HOME%\bin;C:\ProgramData\Oracle\Java\javapath;C:\oraclexe\app\oracle\product\11.2.0\server\bin;C:\Sybase\DataAccess\OLEDB\dll;C:\Sybase\DataAccess\ODBC\dll;C:\Sybase\OCS-12_5\lib3p;C:\Sybase\ADO.NET\dll;C:\Sybase\OLEDB;C:\Sybase\ODBC;C:\Sybase\OCS-12_5\dll;C:\Sybase\OCS-12_5\bin;C:\Program Files (x86)\Windows Resource Kits\Tools\;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;c:\apps\Cygwin\bin;C:\Apps\Tcl\bin;C:\Apps\perl\bin;%CSAM_SOCKADAPTER%bin;C:\PROGRA~2\CA\SC\CAM\bin;c:\Program Files\Java\jdk1.8.0_60\bin;C:\Program Files\TortoiseGit\bin;C:\Program Files (x86)\scala\bin;c:\apps\bin;c:\apps\lib;C:\Program Files\Git\cmd;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;D:\typesafe-activator-1.3.10\activator-dist-1.3.10\bin;C:\Program Files (x86)\sbt\\bin;C:\apache-ant-1.9.6-bin\apache-ant-1.9.6\bin;%GROOVY_HOME%\bin;C:\%GRADLE_HOME%\bin;c:\Program Files (x86)\TextPad 4;C:\Ruby23-x64\bin;D:\gradle-2.13-bin\gradle-2.13\bin;C:\Windows\System32;C:\Program Files\nodejs\;C:\Program Files\SourceGear\Common\DiffMerge\;D:\apps\platform-tools-latest-windows\platform-tools;D:\apps\dependency-check\bin;C:\Program Files\7-Zip;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\nodejs\node_module\.bin;C:\Program Files (x86)\Microsoft VS Code\bin

我还尝试在批处理文件中使用mvn clean installcall mvn clean install,结果相同。

欢迎任何帮助 - 谢谢!

1 个答案:

答案 0 :(得分:2)

mvn的路径添加到环境变量PATH