Maven download, install, set up domestic mirror

1. Download

  Figure 1. Baidu search for maven download, the first link in the figure is the official website download address: http://maven.apache.org/download.cgi , time: April 23, 2020, latest version: 3.6.3

  Figure 2. Entering the link drop-down appears as shown in the picture, the first box indicates that you need to install JDK before using Maven, starting from maven3.3 version, the minimum version of JDK should be 1.7; the second box is the latest windows version we want to download ; The third box is the link to the old version.

2. Installation

  Figure 3. Download and unzip it to the location where you installed the software. It is forbidden to install in a directory containing Chinese and spaces. Then select the address bar of the root directory to copy:

   Figure 4. Configure environment variables: create a new maven_home and edit the path, purpose: to facilitate the later version change and cmd to run the mvn command. maven_home to the root directory, path to the bin directory. Because you must have installed jdk before installing maven, so I will not elaborate on this content in detail. If you don't understand the environment variables, please go to check the JDK related knowledge :

  Figure 5. Verification, cmd input [mvn -v] shows the maven version, indicating that the installation is successful and the environment variable configuration is successful:

 Third, configure the domestic mirror

  Figure 6. The default mirroring address of maven is abroad, so the downloading of jar packages is slow or often fails, so it needs to be changed to a domestic mirror. Open the conf directory under maven, right-click to edit settings.xml, drop down to the location shown in the figure, paste the following code, pay attention to the paste location:

 <mirror>
        <id>aliyunmaven</id>
        <mirrorOf>*</mirrorOf>
        <name>阿里云公共仓库</name>
        <url>https://maven.aliyun.com/repository/public</url>
 </mirror>

  

  Figure 7. You can also change the location where the downloaded jar package is saved, which is the maven repository. The maven repository is saved by default under the .m2 in the C drive user name directory. I have encountered the situation that the directory cannot be read when the project is running, so I prefer to change the location, but do not put it in a directory containing Chinese and spaces. In addition, when there are many jar packages, the entire warehouse can reach several G size or even higher, so you can consider whether to replace other disks yourself:

 

Guess you like

Origin www.cnblogs.com/xfyuao/p/12761527.html