Maven Getting Started Tutorial

1. Maven environment configuration
1. Download: Go to the official Maven website http://maven.apache.org/download.cgi to download the latest version apache-maven-3.1.1-bin.zip
2. Unzip: download to the local zip file, just unzip it to X:\apache-maven-3.1.1 to complete the installation. The directory structure is as follows, similar to the installed JDK.


3. Configure environment variables: This computer->right mouse button->properties->advanced environment settings->environment variables-system variables box under the new variable name M2_HOME, the value is X:\apache-maven-3.1.1, that is In the second step, the installed MAVEN path is similar to JAVA_HOME.



Create a new variable M2 with a value of %M2_HOME%\bin, where there are many executable scripts.


Edit the variable name Path and append ";%M2%" to the variable value.


     4. Test the installation: win+R-> cmd -> enter mvn –version in the command line. If the mvn version information is ApacheMaven 3.1.1, the installation is successful.


Second, configure setting.xml, you can imagine this file as server.xml under tomcat, where maven global configuration is performed.
1. Modify the storage location of the maven warehouse: find the settings.xml configuration file under conf under maven, mine is in D:\apache-maven-3.1.1\conf\settings.xml. The maven repository is placed under the repository under the .m2 folder under the temporary folder of the local user by default, which greatly affects the space of the C drive. Now let's modify it and assign it to our own path. I will now assign the warehouse to the D:\Maven\m2 (you can define the location yourself) directory, so that the downloaded jar package will be stored in this path.


2. Modify the mirror address, this configuration indicates where to download the jar package. Add the following configuration under mirror.

three. MyEclipse or Eclipse environment construction
1. Plug-in installation will not be repeated
2. Configure eclipse: find the Installations under Maven4MyEclipse, add the maven installation directory

3. Find User Settings, select settings.xml in the maven installation directory, and click Update Settings.


OK, eclipse configuration has been completed.
Summary: Through the above three steps, the maven environment construction and eclipse integration are completed.
1. Configure maven environment variables.
2. Modify setting.xml.
3. Configure Eclipse to let Eclipse recognize your maven.
Four. Maven's global command --- pom.xml
pom.xml This file is the core of maven, most Maven commands are implemented by reading the configuration of this file.
This file stores the version of the jar that the project depends on. To put it bluntly, it is like a pointer.
After I configure the maven environment, when we import the project, maven will go to the mirror address to find the corresponding jar version according to the description of the pom.xml file in the project. After the project is imported successfully, maven will download the corresponding jar package to the local library, which is the setting.xml we just configured in the second step. This is the project jar downloaded by my native library.

Open the classpath of eclipse, we found that the jar package of the local library has been successfully introduced.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327016681&siteId=291194637