Where Is the Maven Local Repository?
Maven ~/.m2 repository and settings.xml paths on Windows, macOS and Linux, and how to move the repo off a full drive.
Last updated
Maven caches every downloaded artifact in a local repository under .m2/repository in your home directory. A settings.xml beside it holds mirrors, proxies and credentials. Both live together in the .m2 folder on all three systems.
The localRepo element in settings.xml moves the repository anywhere, which rescues full system drives. Deleting repository contents is safe and forces redownloads on the next build. IntelliJ and Eclipse read the same .m2 tree, so one cleanup helps every IDE. Mirrors in settings.xml redirect downloads through one company proxy.
Where Maven stores this, by platform
C:\Users\[Username]\.m2\repository
Settings live at C:\Users\[Username]\.m2\settings.xml. Add a <localRepo> entry pointing elsewhere to relocate. Delete repository subfolders with IDEs closed.
~/.m2/repository
Same layout as Linux. Homebrew Maven installs still default here. Wrapper scripts like mvnw respect settings.xml in this folder.
~/.m2/repository
CI runners cache this path between builds to skip downloads. Check settings.xml first when artifacts resolve on one machine but not another.
Frequently asked questions
How do I change the Maven repository location?
Edit ~/.m2/settings.xml and set <localRepository>/new/path</localRepository>, then move the repository folder there. Run mvn -o compile once to confirm offline resolution works.
Is it safe to delete ~/.m2/repository?
Yes, with builds closed. Maven redownloads what projects declare. Keep a copy of settings.xml first, since credentials and mirrors are harder to reconstruct.
Notice an outdated path? Let us know.