HowToDoInJava

  • Python
  • Java
  • Spring Boot
  • Dark Mode
Home / Maven / Maven local repository location & how to change it?

Maven local repository location & how to change it?

In this tutorial, learn to change maven local repository location. Maven is build and dependency management tool. It downloads required project dependencies to our local system and include them to project compilation or run-time as defined.

1. Maven’s default local repository location

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

Windows 7: 		C:/Documents and Settings/<username>/.m2/repository
Windows 10:		C:/Users/<username>/.m2/repository
Linux: 			/home/<username>/.m2/repository
Mac: 			/Users/<username>/.m2/repository

We can change local repository location to some other location of our choice.

2. Change maven local repository location

Maven is distributed as archive folder. Generally, developers download the maven and extract it their workstation.

After you have downloaded the maven, follow given simple steps to change maven local repository location to some other path.

  • Navigate to path {M2_HOME}\conf\ where M2_HOME is maven installation folder.
  • Open file settings.xml in edit mode in some text editor.
  • Fine the tag <localRepository>
  • Update the desired path in value of this tag. Save the file.
    	<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
    	   | The path to the local repository maven will use to store artifacts.
    	   |
    	   | Default: ${user.home}/.m2/repository -->
    
    	  <localRepository>E:/devsetup/M2</localRepository>
    
    	  ...
    	  ...
    
     	</settings>
    	
  • Congratulations, You are done.

    Maven local repository path
    Maven local repository path

Happy Learning !!

Was this post helpful?

Let us know if you liked the post. That’s the only way we can improve.

Share this:

  • Twitter
  • Facebook
  • LinkedIn
  • Reddit

About Lokesh Gupta

A family guy with fun loving nature. Love computers, programming and solving everyday problems. Find me on Facebook and Twitter.

Feedback, Discussion and Comments

  1. Durgesh kumar

    January 5, 2020

    thank u so much sir

  2. Mauro

    May 18, 2019

    I had modified the settings.xml in {M2_HOME}\conf\ but maven ignored it, to resolve that just copy that settings.xml to {user.home}/.m2/

  3. Ashish Bhargava

    March 12, 2014

    Which tag needs to be opened? Tag name has not been specified in existing maven installation case. Kindly specify it.

    • Lokesh Gupta

      March 15, 2014

      Thanks for pointing it out. I corrected the post content. It was a formatting error.

      • kaushal

        September 5, 2014

        where have you corrected …….? I m not getting right way to find the settings.xml file in repository plz………make it clear ?

        thank you.

        • Lokesh Gupta

          September 5, 2014

          The content is updated. I again verified it. It you are installing it first time, OR you don’t have the settings.xml file in it’s location then create a new file with name “settings.xml”. Location of file will be C:/Documents and Settings/<current username>/.m2

          Current username is your windows username e.g. admin.

  4. Stanislav

    December 2, 2013

    Thank you!
    Those recommendations was helped me.

Comments are closed on this article!

Search Tutorials

Maven Tutorial

  • Maven – Installation
  • Maven – Settings
  • Maven – Dependency Mgmt
  • Maven – Dependency Scopes
  • Maven – POM
  • Maven – Parent POM
  • Maven – Repositories
  • Maven – Local Repo Path
  • Maven – M2_REPO
  • Maven – Network Proxy
  • Maven – Enforce Java Versions
  • Maven – Simple Java Project
  • Maven – Web Project
  • Maven – Multi-module Project 1
  • Maven – Multi-module Project 2
  • Maven – Java Source Folders
  • Maven – BOM [Bill Of Materials]
  • Maven – Import Remote Catalogs
  • Maven – Create Custom Archetype
  • Maven – Compiler Level Mismatch
  • Maven – Ant Build
  • Maven – IntelliJ
  • Maven – JSTL Support
  • Maven – Tomcat Plugin
  • Maven – Uber Jar for Spring Boot
  • Maven – Shade Plugin
  • Maven – Remove corrupt jars

Meta Links

  • About Me
  • Contact Us
  • Privacy policy
  • Advertise
  • Guest and Sponsored Posts

Recommended Reading

  • 10 Life Lessons
  • Secure Hash Algorithms
  • How Web Servers work?
  • How Java I/O Works Internally?
  • Best Way to Learn Java
  • Java Best Practices Guide
  • Microservices Tutorial
  • REST API Tutorial
  • How to Start New Blog

Copyright © 2020 · HowToDoInjava.com · All Rights Reserved. | Sitemap

  • Java 15 New Features
  • Sealed Classes and Interfaces
  • EdDSA (Ed25519 / Ed448)