MavenWhat is?
Apache Maven is a software project management and understanding tool. Based on the project Object Model (POM) concept, Maven manages project builds, reports, and documentation from a central piece of information.
The above paragraph comes from the official website of the Chinese literal translation!
The role of Maven
- Maven centrally manages all dependencies.
- Maven automatically resolves JAR duplication and conflicts;
- Maven can dynamically integrate plugins that it needs into Maven to extend new management capabilities.
- Maven is a software project management tool that manages project builds, reports, and documentation with a short description based on the project object model.
Maven installation and configuration
Maven is a Java-based project management tool, so the most basic requirement is to have the JDK installed on your computer. If you do not have the JDK installed, you can go to the Java environment setup, configure the JDK, and then go back to configure Maven
download
- Click [Download] to enter the Download page
-
Select Source from Binary
Unpack the
- Once the download is complete, unzip it to the appropriate location: D:\RunEnv\ apache-Maven-3.8.3
Configuring environment Variables
-
Right click on the “Computer” icon, select “Properties”, then click “Advanced System Settings”, click “Environment Variables”. Create a new system variable, MAVEN_HOME, whose value is the Maven installation directory
-
Edit the system variable Path
Note: Click “OK” button all the way to close the window, that is, save the configuration!!
validation
Enter MVN -v from Git Bash or CMD
Maven local Repository
The Maven local repository is actually a directory on the local computer (default: C:%USER_HOME%.m2\repository) that is created the first time a Maven command is executed.
Maven’s local repository stores artifacts needed for all projects locally. When the project is first built, dependencies are automatically searched from the remote repository and downloaded to the local repository. When the project is built again, dependencies are searched and referenced directly from the local repository rather than fetched from the remote repository again.
Modifying a Local Warehouse
Open the settings. XML file under D:\RunEnv\apache-maven-3.8.3\conf and add the following configuration:
<localRepository>D:\RunEnv\repository</localRepository>
Copy the code
Maven mirror
Due to network reasons, downloading components directly from the central warehouse in China is slow or unstable, and may even fail, so we usually use the domestic mirror station of the central warehouse to solve this problem.
To configure Maven mirrors, enter the mirrors TAB in the setting. XML file in the Maven installation directory and add information about mirrors.
-
Ali cloud mirror address
<mirror>
<id>aliyun</id>
<mirrorOf>central</mirrorOf>
<name>aliyun</name>
<url>https://maven.aliyun.com/repository/public</url>
</mirror>
Copy the code
-
Huawei cloud image address
<mirror>
<id>huaweicloud</id>
<name>mirror from maven huaweicloud</name>
<mirrorOf>central</mirrorOf>
<url>https://repo.huaweicloud.com/repository/maven/</url>
</mirror>
Copy the code