Table of contents
2. Configure environment variables
Three verifications are successful
4. Configure the local warehouse
A maven download
1. Select the official website: Apache Maven
2. Find download —— Files —— Binary zip archive (Link) download
3. After the download is complete, put it in your own file directory for direct decompression, do not put it in the file directory (this is why, we don’t know, the reference tutorial says so, we do the same)
ps: Choose the file directory yourself
2. Configure environment variables
1. Enter advanced system settings
Method 1: Select the desktop computer, right-click this computer, and click Properties to enter the system information interface.
Method 2: Through "Control Panel", select "System and Security", then select "System"
Click Advanced System Settings on the left side of the system information interface.
2. In the advanced system settings interface, click Environment Variables
3. Set two attributes in the system variables of the environment variables, MAVEN_HOME and Path. If it exists, "Edit" on this basis; if it does not exist, "New"
3.1 MAVEN_HOME
Create a new MAVEN_HOME variable, the variable value is the MAVEN installation directory
3.2 Path
Edit the Path system variable and create a new value %MAVEN_HOME%\bin
Three verifications are successful
Hold down the shift key and click the right mouse button in the maven directory, select click here to open the powershell window, enter mvn -v (or mvn -version), and it will succeed as shown in the figure (if it is not successful, check whether the cmd directory is correct. Even if it doesn’t work out, we don’t know about it even if we haven’t met it. How about wishing for yourself?)
4. Configure the local warehouse
1. Directly enter maven help:system or mvn help:system in the cmd command prompt just now to configure the maven local library
2. But I suggest you, do not use the command "maven help:system" directly
. If you use it directly, it will put the contents of maven's local library in ${user.home}/.m2/repository on the local disk. If your The local disk is large enough to be ignored. Otherwise modify the installation directory
2.1 Create a new Workspace file in the same level directory of maven just now, and create a new MavenRepository folder in the file directory, which is used as the local library of maven
2.2 Find settings.xml in conf in the maven directory, open the file with Notepad, and enter the following code:
<!-- 下面是自己设置的本地仓库位置-->
<localRepository>MavenRepository文件位置</localRepository>
2.3 Enter the following code in cmd
maven help:system
或
mvn help:system
3. Since the external network download speed is slow, if your speed is fast, you can ignore it. otherwise
Find settings.xml in conf in the maven directory, open the file with Notepad, and enter the following code:
<!-- 设置阿里云镜像-->
<mirror>
<id>alimaven</id>
<mirrorOf>central</mirrorOf>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
</mirror>
4. After successful operation,
will be displayed in cmd
The following files will appear in the MavenRepository folder
success!
Replenish:
In idea, maven’s local warehouse is still c:/user/.m2/repository. When your idea automatically downloads the package for you, it will not be placed in the location you set, so you need to do it in idea Modification, other development tools should be the same.
Modification location: in file - setting (and file - other settings -default settings), search for maven, modify maven home directory and User settings file,
Change the Maven Home directory to the directory of your own maven program. This must be specified, otherwise the Maven program of idea will be used by default.
Change User settings file to settings.xml in your own maven directory config
Note: local repository If you set up your own maven local repository according to the previous steps, you don’t need to modify it at this time, otherwise you need to manually specify the folder directory of your Jar package.
Reference links:
Maven download, install and configure IDEA
Maven installation configuration and configuration in idea