0

Okay so I have been searching for the answer here in SE and came across this comment and several others like it

When Maven tries to build a project, it will look in your local repository (by default ~/.m2/repository but you can configure it by changing the value in your ~/.m2/settings.xml) to find any dependency, plugin or report defined in your pom.xml. If the adequate artifact is not found in your local repository, it will look in all external repositories configured, starting with the default one, http://repo1.maven.org.`

So my question is where is the settings.xml file suppose to reside?

I was told by the previous developers on the project that it is in the maven\conf\settings.xml which is where the only settings.xml file we have is located. This is contradictory to the above comment of .m2/settings.xml.

Please clarify where this file is to reside and if it makes a difference where it is at.

edjm
  • 4,830
  • 7
  • 36
  • 65
  • 1
    Take a look at http://stackoverflow.com/questions/1261215/maven-command-to-determine-which-settings-xml-file-maven-is-using You can of course specify your own location by doing `mvn install -s /path/to/my/settings.xml` – user1717259 Sep 02 '15 at 14:32
  • See [Maven settings documentation](http://maven.apache.org/settings.html) – wjans Sep 02 '15 at 15:04

2 Answers2

2

Both answers are correct.

Basic config file for maven is inside mvn/conf/settings and you could add some configuration (or override basic config) with your personal maven settings file located in ~.m2/settings.xml

Marcin Szymczak
  • 11,199
  • 5
  • 55
  • 63
  • So can this /.m2/ folder be located anywhere or MUST the /.m2/settings.xml location MUST be in my /user/ folder? – edjm Sep 02 '15 at 17:13
  • 1
    main one is m2_home folder, which is place where maven is installed. As for your personal configuration it is in your user folder (for linux it would be /home/Elijah/.m2/settings.xml) – Marcin Szymczak Sep 02 '15 at 20:47
  • This project I'm working in does not seem to follow the convention as the m2 folder that contains the settings xml is in one folder location and the repository is off in some other location. Thank you everyone for this information. – edjm Sep 03 '15 at 15:17
  • This is confusing. Can `settings.xml` be beside `pom.xml` and takes precedence over the other gazillion of other places it could be in? – daparic Nov 06 '20 at 06:16
2

settings.xml file may be found in 2 places:

  • The Maven install: ${maven.home}/conf/settings.xml
  • A user’s install: ${user.home}/.m2/settings.xml

If both files exists, their contents gets merged, with the user-specific settings.xml being dominant.

Ref : https://maven.apache.org/settings.html

Shriram Navaratnalingam
  • 2,847
  • 2
  • 15
  • 20