How to change maven repository folder in windows?

Victor Stafusa picture Victor Stafusa · Dec 20, 2010 · Viewed 41.8k times · Source

In windows, maven downloads everything in the C:\Documents And Settings\MyUser\.m2 folder (or C:\Users\MyUser\.m2). There exists some way to change the folder that it uses? Specially I want to set it to download anywhere BUT in the Documents And Settings/Users folder.

Answer

David picture David · Dec 20, 2010

Look at your settings.xml in ${maven.home}/conf or, preferrably, ${user.home}/.m2/settings.xml (see this for details about the settings.xml). You can add (or uncomment) the following section:

  <!-- localRepository
  | The path to the local repository maven will use to store artifacts.
  |
  | Default: ~/.m2/repository
  -->
 <localRepository>/path/to/local/repo</localRepository>
 

as suggested by the commented out section already there by default. There, you should be able to change the path to achieve what you want.