简体   繁体   English

IntelliJ & Maven - 找不到 mvn 命令

[英]IntelliJ & Maven - mvn command not found

I'm trying to build a drop wizard project created with IntelliJ.我正在尝试构建一个使用 IntelliJ 创建的放置向导项目。 when I run当我跑步时

mvn package

I get我明白了

bash: mvn: command not found

I'm on a Mac and I'm following this tutorial: http://www.dropwizard.io/0.9.2/docs/getting-started.html我在 Mac 上,我正在关注本教程: http://www.dropwizard.io/0.9.2/docs/getting-started.html

According to IntelliJ documentation ( https://www.jetbrains.com/help/idea/2016.1/maven.html?origin=old_help )根据 IntelliJ 文档( https://www.jetbrains.com/help/idea/2016.1/maven.html?origin=old_help

Maven integration is shipped with IntelliJ IDEA, and you do not need to perform any additional actions to install it. Maven 集成随 IntelliJ IDEA 一起提供,您无需执行任何其他操作即可安装它。 You can start using it straight away for importing Maven projects, working with them and for running Maven goals.您可以立即开始使用它来导入 Maven 项目,使用它们并运行 Maven 目标。

So I don't know what I'm suppose to do in order to use the command line Any idea?所以我不知道为了使用命令行我应该做什么知道吗?

Thanks谢谢

In IntelliJ, on the right hand side, click "Maven", and expand "Lifecycle" Select "Package" and click "Run" (green arrow). 在IntelliJ的右侧,单击“Maven”,然后展开“Lifecycle”选择“Package”并单击“Run”(绿色箭头)。

在此输入图像描述

mvn is the command line tool for Maven. mvn是Maven的命令行工具。 See https://maven.apache.org/install.html for details on how to install it. 有关如何安装它的详细信息,请参阅https://maven.apache.org/install.html Or as you are using a Mac if you use brew try using it to install the maven formula. 或者当您使用Mac时,如果您使用brew尝试使用它来安装maven公式。

If you have maven properly installed and you want to configure intelliJ terminal with a custom Terminal or if you want fix "command not found", follow these steps:如果您已正确安装 maven 并且您想使用自定义终端配置 intelliJ 终端,或者如果您想修复“找不到命令”,请按照下列步骤操作:

  1. Click > File单击 > 文件
  2. Click > Settings单击 > 设置
  3. Click > Tools单击 > 工具
  4. Click > Terminal点击 > 终端
  5. Edit "Shell path" @ "Application Settings", if you use git bash change current path with: C:\Users\Work\AppData\Local\Programs\Git\bin\sh.exe --login编辑“Shell 路径”@“应用程序设置”,如果您使用 git bash 更改当前路径为: C:\Users\Work\AppData\Local\Program

// The path you may have differs based on your OS, in example: "installationPath\Terminal Folder\bin\sh.exe --login" // 您的路径可能因您的操作系统而异,例如:“installationPath\Terminal Folder\bin\sh.exe --login”

  1. Click > Apply单击 > 应用
  2. Click > Ok单击 > 确定

I used git bash but technically it should work with every terminal.我使用了 git bash 但从技术上讲它应该适用于每个终端。 Do not forget to add --login after the *.exe不要忘记在 *.exe 之后添加 --login

If it still doesn't work maybe you need to check:如果它仍然不起作用,您可能需要检查:

  1. Click > Environment variables单击 > 环境变量
  2. Click > System Properties单击 > 系统属性
  3. Click > Environment Variables单击 > 环境变量
  4. Click > System Variables单击 > 系统变量
  5. Select > Path from the list Select > 列表中的路径
  6. Click > Edit单击 > 编辑
  7. Click > New单击 > 新建

Insert the path of your maven bin folder, in example:插入 maven bin 文件夹的路径,例如:

  • "installationPath\apache-maven-3.8.6\bin" “安装路径\apache-maven-3.8.6\bin”

Also insert the path of your jdk, in example:还要插入你的 jdk 的路径,例如:

  • "installationPath\Java\jdk-18.0.1.1" “安装路径\Java\jdk-18.0.1.1”

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

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