Maven installation and configuration (the thief is detailed ~)

1. Things to prepare

1. JDK

2. Eclipse

3. Maven package

2. Download and install

1. Go to Maven – Download Apache Maven to download the latest version of the Maven program:

What I downloaded is: apache-maven-3.9.2-bin.zip

 2. Create a new directory D:\Program Files\Apache\maven under the Program Files folder of the D disk, and extract the file to the D directory:

3. Right-click This Computer--Properties--Advanced System Settings--Advanced--Environment Variables--New

 

 4. New environment variable variable name: MAVEN_HOME, variable value: D:\Program Files\Apache\maven 

 5. Edit the environment variable Path, and create a new %MAVEN_HOME%\bin\

 

 6. Now that maven has been installed, we can check whether we have successfully installed it through the DOS command:

mvn -v

 3. Configure Maven local warehouse

1. Create a new maven-repository folder in the D:\Program Files\Apache\ directory, which is used as the local library of maven.

2. Open the D:\Program Files\Apache\maven\conf\settings.xml file and find the following line of code:

<localRepository>/path/to/local/repo</localRepository>

 The localRepository node is commented out by default, you need to move it out of the comment, and then change the value of the localRepository node to the directory D:\Program Files\Apache\maven-repository we created in 3.1.

3. The localRepository node is used to configure the local repository. The local repository actually acts as a cache. Its default address is C:\Users\username.m2. When we get the jar package from maven, maven will first look it up in the local warehouse, if there is one in the local warehouse, it will return; if not, it will 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.

4. Run the DOS command

mvn help:system

If the previous configuration is successful, some files will appear in D:\Program Files\Apache\maven-repository.

Fourth, configure the Maven environment of Eclipse

1. Open Eclipse --Window-Preferences--Maven--Installations, click Add on the right, set the maven installation directory, and then Finish.

 2. Select the maven just added, and Apply.

 3. Open Window->Preferences->Maven->User Settings, configure as follows and Apply:

 At this point, the installation and configuration of Maven are all over.

추천

출처blog.csdn.net/m0_65065082/article/details/130727836