How to configure mavan

一、需要准备的东西
  1. JDK

  2. Eclipse

  3. Maven package

2. Download and install

  1. Go to https://maven.apache.org/download.cgi to download the latest version of the Maven program:
    Insert picture description here

  2. Unzip the file to the D:\Program Files\Apache\maven directory:
    Insert picture description here

  3. Create a new environment variable MAVEN_HOME and assign it to D:\Program Files\Apache\maven
    Insert picture description here

  4. Edit the environment variable Path and append %MAVEN_HOME%\bin;
    Insert picture description here

  5. At this point, Maven has completed the installation, we can check whether we installed it successfully through the DOS command:
    Insert picture description here
    Third, configure the Maven local warehouse

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

  7. Open the D:\Program Files\Apache\maven\conf\settings.xml file and find the following line of code:
    /path/to/local/repo

The localRepository node is commented out by default, you need to move it outside 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.

  1. The localRepository node is used to configure the local repository. The local repository actually functions 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, and return it if there is one in the local warehouse; 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.

  1. 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 Eclipse's Maven environment

  1. Eclipse Oxygen, open Window->Preferences->Maven->Installations, click Add on the right.
    Insert picture description here
  2. Set the installation directory of maven, and then Finish
    Insert picture description here
  3. Select the maven you just added and Apply.
    Insert picture description here
  4. Open Window->Preferences->Maven->User Settings, configure the following and Apply:
    Insert picture description here

The installation and configuration of Maven is all over.

Guess you like

Origin blog.csdn.net/weixin_44941105/article/details/95386206