Change Maven repository directory within Eclipse

If you use the embedded Maven installation within Eclipse, the default .m2 directory (which contains the repository) resides in the profile of the current user.

In Windows, this is the C:\Documents and Settings\<user> directory. A large repository there could result in problems with server based profiles. Is there a quota on the server, it could be not possible to save the profile back to the server, if it contains a lot of Maven artifacts.

You can set the repository directory within the settings.xml. Copy the .m2 directory into another path on your computer (outside of your profile). Edit the settings.xml and set a new path to your repository:

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

Enter Eclipse Preferences and change the User Settings path. Click on “Update Settings” and the Local Repository should be changed to the path defined within your settings.xml. Click on “Reindex”.

Eclipse Maven Settings

Last but not least, delete the .m2 folder from your profile directory.

Leave a Reply