【问题标题】:maven not recognized in intellijmaven 在 Intellij 中不被识别
【发布时间】:2018-08-30 17:02:23
【问题描述】:

在运行 spring-boot 服务器时,我确实在 intellij 中收到了此错误消息:

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

当我尝试构建位于我的项目文件夹中的项目时,它无法识别 maven: mvn spring-boot:run

我通过下载 maven 解决了这个问题:https://maven.apache.org/install.html 并手动将 apache-maven-3.5.3 文件夹中的 bin 文件添加到库中

似乎有点倒退。还有其他/更好的方法吗?

【问题讨论】:

  • 尝试将C:\your\path\to\maven\bin添加到Windows的Path环境变量中。
  • IntelliJ 有built in support for maven projects。您对 'mvn' 的提及无法识别 表明您正在尝试手动调用 maven,可能是从终端窗口?!您不应该在项目中添加与 Maven 安装相关的任何内容。您可以从 maven 工具窗口 轻松构建您的项目或运行插件,只需查看我提供的快速介绍链接即可。或者,如果您更喜欢使用终端/控制台,请遵循 @ImpulseTheFox 的建议
  • "手动调用 maven,可能来自终端窗口" intellij 内没有。
  • 但它是 InteliJ 的终端窗口吗?如果您“键入” mvn 命令,则基本上是转发到操作系统终端。因此,您需要正确设置 PATH-Entry。
  • 正是我的意思,您实际上并没有使用 IJ 的 maven 支持。您正在使用“OS 终端包装器”,基本上将mvn 命令的执行委托给终端。由于您的系统尚未配置,它不知道mvn 是什么意思。 @ImpulseTheFox 已经为此提供了提示。回到 IJ 中的 maven 支持,您可以使用 Maven Projects 工具窗口(来自之前提供的 IJ Maven 帮助链接的this one)来执行您的构建,而无需依赖操作系统配置。

标签: java maven intellij-idea


【解决方案1】:

如果通过:http://maven.apache.org/download.cgi 和:'mvn' is not recognized as an internal or external command, operable program or batch file 手动安装 Maven。只需重新启动您的 IntelliJ IDEA 并再次运行您的 spring-boot 服务器!

【讨论】:

    【解决方案2】:

    就我而言,我不得不取消选中Shell integration

    IntelliJIDEA 菜单 -> 首选项 -> 工具 -> 终端

    enter image description here

    【讨论】:

      【解决方案3】:

      在 Windows 中以管理员身份运行您的 intellij

      【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-04-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-01
      相关资源
      最近更新 更多