What is maven local repository location & how to change it?

By | October 31, 2020

In this post, We will learn about What is maven local repository location & how to change it?

Maven downloads the required artifacts or dependencies (jar files) and other plugins which are configured as part of any project, there must be a commonplace where all such artifacts are placed. This common shared area is called a Repository.

Local Repository:

This repository usually resides in our local machine. Which is cached from the remote/central repository downloads and ready for usage/reuse.

The directory to store all the dependencies in the local machine can be configured in the settings.xml file of the maven directory under the tag <localRepository>

1. Maven’s default local repository location

By default maven’s local repository exists on ‘${user.home}/.m2/repository’. In different operating systems, these paths are resolved to –

We can easily change the local repository path or location to some other location of our choice.

2. Change maven local repository location

Maven is distributed and downloaded as an archive folder. Generally, Software developers download the maven and extract it from their local machine

Once we download the maven, follow the given simple steps to change the maven local repository location to some other path.

  • Navigate to path {M2_HOME}\conf\ where M2_HOME is the maven installation directory.
  • Open file settings.xml file in edit mode in some text editor.
  • Find the tag <localRepository> in settings.xml
  • Update the desired path(e.g C:/kkjavaRepo) in the value of this tag. Save the file.
    setting.xml

    Now if you build your maven project then all the dependencies will be downloaded from the central repository and stored in the above configured local repository path : C:/kkjavaRepo

That’s all about What is maven local repository location & how to change it?

You May Also Like:

What is Maven?
How to install and setup Maven Environment on windows?
Create a maven project using the command line
How to import the maven project in Eclipse?
How to Create a New Maven Project in Eclipse
How to create a maven web application project in Eclipse
How to create a multi-module project using maven?
How to Fix missing src/main/java & src/test/java folders in the Eclipse Maven web Project?
How to create user-defined properties in Maven?
How to add or update the maven settings.xml file in eclipse?
Importing maven remote Archetype Catalogs in eclipse ?
What is POM in the maven Project?
What is Super POM in Maven Project?
Understanding the purpose of Maven Plugin
Compiling the Maven project with different JDK versions? 
Understanding of settings.xml in maven
How to enable a proxy setting in Maven?
Maven Dependency Scopes
How to generate javadoc in the maven Project
How to create a runnable JAR file with Maven?
How to add local jar files to a Maven project?
How to convert an existing Java Project to Maven in Eclipse?
How to exclude dependency in maven?
Managing External Dependencies in maven
Understanding of Maven Repositories
What is an archetype in Maven?
Snapshot Vs Version in maven
Apache Maven – Profiles

If you have any feedback or suggestion please feel free to drop in below comment box.

Leave a Reply

Your email address will not be published. Required fields are marked *