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