1. Maven installation and configuration environment variables (the picture shows windows 7, windows10 is the same)
#1 First, you should have downloaded and installed the JDK and configured the environment variables
#2 Search Maven in the browser, enter Maven's official website to download and unzip it (currently the latest version is apache-maven-3.6.0-bin.zip)
#3 Then configure the environment variable, create a new environment variable MAVEN_HOME and assign a value. The variable value is the address of your installation.
(My installation path is E:\maven\apache-maven-3.6.0)
#4 Update the Path value, edit the environment variable Path under windows 7, and append the variable value;%MAVEN_HOME%\bin
(update the Path under windows10, and create a new variable value %MAVEN_HOME%\bin)
(The windows7 shown in the picture is the encounter mentioned below to the case of incorrectly modifying the value of a variable)
#5 Verify whether it is successful, enter mvn -version in cmd, if you see the picture below, it is correct
What went wrong:
If the following error conditions occur
solution
This may be because the original variable was overwritten when setting the environment variable Path, just change the original ;%MAVEN_HOME%\bin to ;%SystemRoot%\system32;%maven_home%\bin after the path and repeat #5 to check whether it is
successful .
2. Configure the Maven local warehouse (beginners can also use the default warehouse, which is in C:)
-
Create a new maven-repository folder under E:, which is used as maven's local warehouse.
-
Open the E:\maven\conf\settings.xml file, find the localRepository tag, find the following line of code and modify the middle content to:
<localRepository>E:/maven-repository</localRepository>
- The localRepository node is used to configure the local warehouse. The local warehouse actually acts as a cache. Its default address is C:\Users\username.m2.
When we get the jar package from maven, maven will first search in the local warehouse, and return if the local warehouse has it; if not, get the package from the remote warehouse and save it in the local warehouse.
In addition, we run mvn install in the maven project, and the project will be automatically packaged and installed in the local warehouse.
- Run the DOS command mvn help:system
if the previous configuration is successful as shown in the figure below
Notice
If you have not modified the local warehouse, run the DOS command mvn help:system and the following error will appear.
Solution:
add the bottom <mirror code under the mirror in E:\maven\conf\settings.xml.
The above is the summary of my study and the errors and solutions I encountered. I hope it can help everyone. If you have any questions, you can comment and we can solve them together!