Maven Learning (iii)--modifying the MAVEN local default repository

Source: Internet
Author: User
Tags maven central

Modify the default storage location for the jar packages downloaded from the MAVEN central repository to the local

The default storage of the jar packages downloaded from the MAVEN central warehouse to the local is in "${user.home}/.m2/repository", and ${user.home} represents the user directory (such as "C:\Users\gacl") that is currently logged into the system, as shown in

  

  

The jar package is not very good to store in this location, we would like to be able to define the location of the downloaded jar package, so we can set ourselves to download to the local jar package storage directory.

Create a "repository" folder under the "E:\" directory

  

Locate the settings.xml file in the apache-maven-3.2.3\conf directory, as shown in:

  

Edit the Setting.xml file as shown in:

  

Add the following code

1 <localRepository>E:/repository</localRepository>

  

This allows the jar package to be downloaded to our specified e:/repository directory, as shown in:

  

The advantage of downloading the jar package to the local is that when it is compiled, it will take precedence from the local jar package, and if it exists locally, it will be used directly, and if it does not exist, it will be downloaded from the MAVEN central repository. As shown in the following:

  

The first time you execute the "mvn compile" and "mvn clean" commands, MAVEN will go to the central repository to download the required jar packages, and the second time you execute the two commands, you can use them directly because the required jar packages are already stored in the local repository. This eliminates the time to download the jar package to the central warehouse.

Maven Learning (iii)--modifying the MAVEN local default repository

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.