Fixing Missing Maven .m2 Folder





Hey.. I'm gonna share you the way how to fixing missing .m2 folder.

There's one thing that I know, both in macOS or Ubuntu the .m2 folder is expected to be located under ${user.home}.

Check .m2 folder at {user.home}

First thing you should do is check your directory $(user.home). 

As I said before, that ideally .m2 folder should be at {user.home}/.m2. If can't seem to find it in this directory, try to show hidden files because .m2 is hidden by default.

To show hidden files on macOS, you can try this quickest way by pressing this shortcut:

COMMAND + SHIFT + .

If you still can't find the .m2 folder after showing hidden files, try this way.



Try to create .m2 folder manually

If you have used brew to install apache maven before, you should create manually .m2 directory by using this command.

mkdir ~/.m2
cp /usr/local/Cellar/maven32/3.6.3/libexec/conf/settings.xml ~/.m2


Don't forget to change the maven version in the path as yours.

Copy settings.xml

After creating .m2 folder, copy settings.xml to .m2 directory.
For an example, settings.xml should be looks like this:

<settings xmlns="http://maven.apache.org/POM/4.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
  http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <localRepository>
    ~/.m2/repository
  </localRepository>
  <interactiveMode>true</interactiveMode>
  <usePluginRegistry>false</usePluginRegistry>
  <offline>false</offline>
</settings>


Don't forget to change the 'localRepository' path as yours.

You also can see the settings refference here.

Comments