如何在Windows上安装Maven

Apache Maven is the most popular project management tool for Java applications. We can install maven on any operating system.

Apache Maven是最流行的Java应用程序项目管理工具。 我们可以在任何操作系统上安装maven。

在Windows上安装Maven (Installing Maven on Windows)

Maven requires JDK to execute. Maven 3.3+ requires JDK 1.7 or above to execute. Let’s look into the various steps to install Maven on Windows.

Maven需要JDK执行。 Maven 3.3+需要JDK 1.7或更高版本才能执行。 让我们研究在Windows上安装Maven的各种步骤。

1.在Windows上安装JDK (1. Install JDK on Windows)

We can install Oracle JDK using the executable file. But, for this tutorial, we will install OpenJDK. OpenJDK is free to use and we don’t need to worry about licenses or to pay Oracle for support.

我们可以使用可执行文件安装Oracle JDK。 但是,对于本教程,我们将安装OpenJDK。 OpenJDK是免费使用的,我们无需担心许可证问题或向Oracle支付支持费用。

1.1)下载OpenJDK Binaries ZIP文件 (1.1) Download OpenJDK Binaries ZIP File)

Go to the JDK Download URL: https://jdk.java.net/13/

转到JDK下载URL: https : //jdk.java.net/13/

Download the binaries for Windows/x64 as shown in the below image.

下载Windows / x64的二进制文件,如下图所示。

Download Openjdk Windows

Download OpenJDK for Windows

下载适用于Windows的OpenJDK

Extract it to any place you want. I have extracted it to C:\Program Files\Java folder.

将其解压缩到您想要的任何位置。 我已将其解压缩到C:\Program Files\Java文件夹。

1.2)设置环境变量– JAVA_HOME和Path (1.2) Setting up Environment Variables – JAVA_HOME and Path)

We have to set JAVA_HOME and add the JDK binaries folder to the Path variable.

我们必须设置JAVA_HOME并将JDK Binaries文件夹添加到Path变量。

You can search for “edit environment variables” or go to “Control Panel -> System and Security -> System” and click on the “Advanced system settings” link in the left sidebar.

您可以搜索“编辑环境变量”或转到“控制面板->系统和安全性->系统”,然后单击左侧栏中的“高级系统设置”链接。

In the “System Properties” popup, go to the “Advanced” tab and click on the “Environment Variables” button. This will open a new popup window to edit user and system environment variables.

在“系统属性”弹出窗口中,转到“高级”选项卡,然后单击“环境变量”按钮。 这将打开一个新的弹出窗口,以编辑用户和系统环境变量。

Now, create a new system environment variable “JAVA_HOME” with value as the location of the JDK folder.

现在,创建一个新的系统环境变量“ JAVA_HOME”,其值作为JDK文件夹的位置。

Also, add the JDK bin folder to the Path variable list of directories.

另外,将JDK bin文件夹添加到目录的Path变量列表中。

1.3)通过命令提示符验证Java安装 (1.3) Verifying Java Installation through Command Prompt)

Open the command prompt and type java -version command. It should print the JDK version installed by you.

打开命令提示符,然后键入java -version命令。 它应该打印您安装的JDK版本。

Check Java Version Command Prompt

Check Java Version Command Prompt

检查Java版本命令提示符

2.在Windows上安装Maven (2. Install Maven on Windows)

Once the JDK is properly installed and configured, we can move ahead with the installation of the maven.

一旦正确安装并配置了JDK,我们就可以继续安装Maven。

2.1)下载Maven Binary zip存档 (2.1) Download Maven Binary zip Archive)

Go to the URL: https://maven.apache.org/download.cgi

转到URL: https : //maven.apache.org/download.cgi

Download the “Binary zip archive” as shown in the below image.

如下图所示,下载“二进制zip存档”。

Download Maven Binary Zip Archive

Download Maven Binary Zip Archive

下载Maven Binary Zip存档

2.2)设置Maven环境变量– M2_HOME,MAVEN_HOME,路径 (2.2) Setting up Maven Environment Variables – M2_HOME, MAVEN_HOME, Path)

First of all, extract the downloaded maven zip file to any folder of your choice. I have extracted it to C:\Program Files\apache-maven-3.6.3.

首先,将下载的maven zip文件解压缩到您选择的任何文件夹中。 我已经将其提取到C:\Program Files\apache-maven-3.6.3

Now, use the below image to create the M2_HOME and MAVEN_HOME variables. Also, add the maven bin folder to the Path variable.

现在,使用下图创建M2_HOME和MAVEN_HOME变量。 另外,将maven bin文件夹添加到Path变量。

Setting Maven Environment Variables

Setting Maven Environment Variables

设置Maven环境变量

2.3)通过命令提示符验证Maven安装 (2.3) Verifying Maven Installation through Command Prompt)

Open command prompt and type mvn -version command. It should print the maven version, maven bin folder location, and the Java version it’s using.

打开命令提示符,然后键入mvn -version命令。 它应该显示Maven版本,Maven Bin文件夹位置以及所使用的Java版本。

Checking Maven Version Command Prompt

Checking Maven Version Command Prompt

检查Maven版本命令提示符

That’s it. Maven is successfully installed and you can use it to create and manage Java projects.

而已。 Maven已成功安装,您可以使用它来创建和管理Java项目。

参考资料 (References)

翻译自: https://www.journaldev.com/33567/install-maven-windows

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值