java Maven 构建错误:无法识别 mvn.bat

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32706000/
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-11-02 20:38:46  来源:igfitidea点击:

Error in Maven build: mvn.bat not recognized

javamavenbatch-filenetbeans

提问by Luís Soares

While trying to build a Java project under NetBeans (with an external Maven configured), I got the following error:

在尝试在 NetBeans 下构建 Java 项目(配置了外部 Maven)时,出现以下错误:

"C:\Users......\bin\mvn.bat"" is not recognized as an internal or external command, operable program or batch file"

"C:\Users......\bin\mvn.bat"" 不是内部或外部命令,也不是可运行的程序或批处理文件"

Edit: Using Maven 3.3.3, Windows 10; Added custom maven to NetBeans under Tools > Options > Java > Maven > Execution > Maven Home > Browse

编辑:使用 Maven 3.3.3,Windows 10;在“工具”>“选项”>“Java”>“Maven”>“执行”>“Maven 主页”>“浏览”下向 NetBeans 添加了自定义 Maven

What can I do?

我能做什么?

回答by Luís Soares

To solve it:

要解决它:

  1. Go to the Maven installation folder
  2. Go to bin
  3. Make sure you can see file extensions
  4. Duplicate mvn.cmdand mvnDebug.cmdand rename those copies to have the extension .bat
  5. Try building the project now
  1. 进入Maven安装文件夹
  2. bin
  3. 确保您可以看到文件扩展名
  4. 复制mvn.cmdmvnDebug.cmd重命名这些副本的扩展.bat
  5. 立即尝试构建项目

source

来源

回答by Chic

Install Netbeans 8.1 or later to correct this issue.

安装 Netbeans 8.1 或更高版本以更正此问题

As @mkleint noted, this is a problem with Maven 3.3.3+ where maven changed the mvn executable extension.You can downloadthe latest version on the Netbeans website.

正如@mkleint指出的,这是 Maven 3.3.3+ 的问题,其中 maven 更改了 mvn 可执行文件扩展名。您可以在 Netbeans 网站上下载最新版本。

回答by Christophe

Maven 3.3+ has no more mvn.bat you should use version 2.5.2+ of the maven-release-plugin : https://issues.apache.org/jira/browse/MRELEASE-902

Maven 3.3+ 没有 mvn.bat 你应该使用 maven-release-plugin 的 2.5.2+ 版本:https://issues.apache.org/jira/browse/MRELEASE-902