prerequisites:
- Maven3.3.* or above, requires support of JDK1.7 or above
- Maven3.2.* version requires JDK1.6 support
- Maven 3.0/3.1, requires JDK 1.5 or above
- Make sure the JDK is installed and the "JAVA_HOME" variable has been added to the Windows environment variables
1. Maven download address
Official website download address: Maven – Download Apache Maven
Click the zip package to download to the local
2. Installation and configuration
1. Installation
Unzip the downloaded zip package (apache-maven-3.8.5-bin.zip) to the local directory;
Local directory: D:\Program Files\apache-maven-3.8.5
2. System environment variable configuration
Variable name: M2_HOME
Variable value: D:\Program Files\apache-maven-3.8.5
Variable name: MAVEN_HOME
Variable value: D:\Program Files\apache-maven-3.8.5
Displayed after adding variables:
Variable name: Path
variable:
%M2_HOME%\bin
%MAVEN_HOME%\bin
3. Test it
cmd run command: mvn –version
You can see the maven version number as shown in the figure below, which means that the installation and configuration are successful;
3. Use the installed Maven in the IDEA project
1. The IDEA tool is set to use the installed Maven
Operation: File - Settings - Build, Execution, Deployment - Build Tools - Maven
Maven main path selection: D:/Program Files/apache-maven-3.8.5, click Apply to take effect;
2. Configure Maven's user settings file
Find the local user settings file (if you don't add your own settings.xml file):
C:\Users\nikey\.m2\settings.xml
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<!-- localRepository
| The path to the local repository maven will use to store artifacts.
|
| Default: ${user.home}/.m2/repository
-->
<mirrors>
<!-- 阿里云镜像 -->
<mirror>
<id>nexus-aliyun</id>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
<!-- 给定仓库的下载镜像。 -->
<mirror>
<!-- 该镜像的唯一标识符。id用来区分不同的mirror元素。 -->
<id>alimaven</id>
<!-- 镜像名称 -->
<name>aliyun maven</name>
<!-- 该镜像的URL。构建系统会优先考虑使用该URL,而非使用默认的服务器URL。 -->
<url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
<!-- 被镜像的服务器的id。例如,如果我们要设置了一个Maven中央仓库
(http://repo.maven.apache.org/maven2/)的镜像,就需要将该元素设置成central。这必须和中
央仓库的id central完全一致。 -->
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
</settings>
3. IDEA compiles and runs locally, and downloads project dependencies to the local warehouse
Use the Maven plug-in in IDEA, run the compilation, and then download the project dependencies to the local warehouse
Local repository: C:\Users\nikey\.m2\repository