0

I am using apache-maven-3.2.3

It is located at C:\java\apache-maven-3.2.3

The settings.xml file is located C:\java\apache-maven-3.2.3\conf\settings.xml

Inside that settings.xml file, I have the following defined:

<localRepository>C:/java/maven_repo</localRepository>

I have windows environment variables defined:

  • M2_HOME=C:\java\apache-maven-3.2.3
  • M2=%M2_HOME%\bin
  • PATH environment variable includes %M2%

I have configures my STS (Eclipse) to use the external Maven installation at C:\java\apache-maven-3.2.3

My STS Maven-->Installations shows that the global settings are: C:\java\apache-maven-3.2.3\conf\settings.xml

My STS Maven-->User Settings shows that the local repository from merged and global settings is: C:\java\maven_repo

There is NO settings.xml at C:/Users/[myuser]/.m2

In fact, I remove the entire .m2 folder at C:/Users/[myuser]/.m2 to be sure

However, When I do a Maven update through STS, it is still downloading artifacts to the default .m2 directory at: C:/Users/[myuser]/.m2/repository

My Eclipse project is also showing the Maven Dependencies are found in C:/Users/[myuser]/.m2/repository

Can anyone tell me why? What have I done wrong? Why wont it use the local repository at c:/java/maven_repo ?

2
  • Could you please clarify why you edited the global settings.xml inside the Maven installation instead of defining one in $USER_HOME/.m2? What you're attempting is not the typical way a local repo location is defined.
    – user944849
    Nov 12, 2014 at 16:04
  • We are standardizing everyone's development environments in the team with the same folder structure etc. So we have a "customized" Maven installation zip file which all new team members will simply extract into their c:/Java folder, and this Maven installation has a settings.xml which is pre-configured to our environment. We basically want everything contained in the same folder structure, not scattered about in personal "user" folders etc.
    – dleerob
    Nov 13, 2014 at 12:49

2 Answers 2

0

Normally, I will change the default local repository folder from default .m2 to another more meaningful name, for example, maven-repo.


Find {M2_HOME}\conf\setting.xml, update localRepository to something else.

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

    <localRepository>D:/maven_repo</localRepository>


Done, your new Maven local repository is now changed to D:/maven_repo.

1
  • this worked worked for me, this is from MKYONGs tutorial
    – VedantK
    Nov 12, 2014 at 11:56
0

The only way I have managed to get this to work in Eclipse is to also set the user settings file in Window-->Preferences-->Maven-->User Settings to the same as the global settings: C:\java\apache-maven-3.2.3\conf\settings.xml

But I would imagine that leaving that field blank should take the settings from the global settings.xml, but for some reason it doesn't. So if I leave that user settings field blank, the localRepositorty from global settings.xml does not apply.

However, if I run Maven outside eclipse, it works as expected.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.