Java 安装Maven 3.3.9,如何设置M2_HOME、MAVEN_HOME和bin文件夹?

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

Installing Maven 3.3.9, how to set M2_HOME, MAVEN_HOME and bin folder?

javamavenpathhome-directory

提问by azalut

I am trying to install Maven 3.3.9 on my new laptop but it seems to be incredibly difficult. I am not sure what changed since versions 3.0 which I have been mostly using but now I cant set M2_HOME, MAVEN_HOMEand PATHvariables properly.

我正在尝试在我的新笔记本电脑上安装 Maven 3.3.9,但这似乎非常困难。我不知道,因为我已经大多采用版本3.0是什么改变了,但现在我不能设置M2_HOMEMAVEN_HOME以及PATH变量正常。

Maven home page tells me to set it like this:

Maven 主页告诉我这样设置:

  • MAVEN_HOME: C:/apache-maven-3.3.9
  • M2_HOME: C:/apache-maven-3.3.9
  • PATH: C:/apache-maven-3.3.9/bin
  • MAVEN_HOME:C:/apache-maven-3.3.9
  • M2_HOME:C:/apache-maven-3.3.9
  • PATH: C:/apache-maven-3.3.9/bin

but that, as you may guess, doesn't work. Whats more, there is even no binfolder inside apache-maven-3.3.9! I have found directory: C:/apache-maven-3.3.9/apache-maven/src/binbut it doesn't help as well.

但是,正如您可能猜到的那样,这是行不通的。更何况binapache-maven-3.3.9里面连文件夹都没有!我找到了目录:C:/apache-maven-3.3.9/apache-maven/src/bin但它也没有帮助。

How to set it properly?

如何正确设置?

回答by Tunaki

It seems you downloaded the wrong distributed archive from the Maven website: you downloaded the source and not the binary.

您似乎从 Maven 网站下载了错误的分布式存档:您下载的是源代码而不是二进制文件。

Going to the download page, you need to choose the "Binary zip archive" (or "Binary tar.gz archive"). After that, you can follow the installation steps from the install pagebut the steps are really straight-forward:

转到下载页面,您需要选择“二进制 zip 存档”(或“二进制 tar.gz 存档”)。之后,您可以按照安装页面中的安装步骤进行操作,但这些步骤非常简单:

  • Ensure JAVA_HOMEenvironment variable is set and points to your JDK installation
  • Extract distribution archive in any directory
  • Add the bindirectory of the created directory apache-maven-3.3.9to the PATHenvironment variable
  • 确保JAVA_HOME环境变量已设置并指向您的 JDK 安装
  • 在任何目录中提取分发存档
  • bin将创建目录的目录添加apache-maven-3.3.9PATH环境变量中

There is no need to set the M2_HOMEor MAVEN_HOMEenvironment variable.

不需要设置M2_HOMEorMAVEN_HOME环境变量。

回答by mmizutani

If you want to keep your maven installation always up-to-date, it is easier to install it via Homebrew on Mac OS X or Linuxbrew on Linux.

如果你想让你的 maven 安装总是最新的,通过 Mac OS X 上的 Homebrew 或 Linux 上的 Linuxbrew 安装它会更容易。