'Maven points to a strange local repository directory

When I try to use Maven from command line or Intellij, it points to a local repository c:\Users\username\subir.m2\repository instead of c:\Users\username.m2\repository . It happens only when I use another Java than the default Java 11.

I checked the settings.xml of maven, but it seems ok. I also added manually the default local repository without success.

On command line, I can force the repo using -Dmaven.repo.local. In Intellij I don't know how to point to the correct repository. Settings under Maven -> Repositories are ok.

EDIT: as suggested by Anthony, in Settings -> Build, Execution, Deployment -> Build Tools -> Maven I simply clicked Override near User settings and Local repository, leaving the default values, and it worked.

Of course, on the command line it continues to point to the bad path. Is there not a way to change that, without using everytime -Dmaven.repo.local?



Solution 1:[1]

Normally, you can always override the local repository you wants to use following this path :

Preferences > Build, Execution, Deployment > Build Tools > Maven and then check "Override" to add your custom local repository

Settings Menu on IntelliJ

You can also precise your local repository by adding this to your setting.xml : "< localRepository > /Path/Of/Your/Repo < /localRepository >"

Hope it helps

Solution 2:[2]

In your intellij idea, you can change it from Settings > Maven enter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Anthony LEWANDOWSKI
Solution 2 Syed Mainul Hasan