There are three types of Maven repositories:
You will have seen Maven downloading a number of files (called poms and jars). Let us see where they are located in your computer:
HOME
folder (C:Usersusername
) in the case of Microsoft Windows, /Users/username
for Mac, and, /home/username
(or a similar location) for Linux.m2
folder and within that, a subfolder called repository
You may want to change this location for the following reasons:
C
drive and store these folders and files in the D
drive on Microsoft Windows.To change the location of the Maven repository, perform the following steps:
settings.xml
in the .m2
folder.<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>C:/software/maven</localRepository>
</settings>
Notice the highlighted part of the preceding code. We have changed the location of the repository contents to C:softwaremaven. You can change it to any valid folder name.
repository
subfolder and run the mvn package
command again.You will now notice that the repository
folder is not created in the .m2
folder. Instead, it is created in C:softwaremaven
.
Maven determines the location of the local repository in the following way:
settings.xml
exists in the user's .m2
folder, which contains the <localRepository>
tag, then Maven uses its contents to determine the locationlocalRepository
is explicitly defined in the default settings.xml
, present in the conf
folder of the Maven installation.m2
folder3.133.124.21