147

I recently changed my password and have to change my maven settings.xml file to reflect that. However, no matter what I do in the settings.xml file, the changed password just won't get picked up. Out of desperation, I ran maven with the -s switch (mvn -s <my intended settings.xml file>) and everything just started working. It seems to suggest that maven by default is using a "wrong" settings.xml

Is there a way for me to figure out where the settings.xml file that maven is using is located?

Ciro Santilli OurBigBook.com
  • 347,512
  • 102
  • 1,199
  • 985
RAY
  • 6,810
  • 6
  • 40
  • 67
  • 2
    Duplicate for http://stackoverflow.com/questions/1261215/which-maven-settings-xml-files – nwinkler Apr 03 '12 at 07:27
  • Actually, The other question has no answer that I needed. nico_ekito provided with the answer that I need. – RAY Apr 03 '12 at 07:38

2 Answers2

272

Use the Maven debug option, ie mvn -X :

Apache Maven 3.0.3 (r1075438; 2011-02-28 18:31:09+0100)
Maven home: /usr/java/apache-maven-3.0.3
Java version: 1.6.0_12, vendor: Sun Microsystems Inc.
Java home: /usr/java/jdk1.6.0_12/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "2.6.32-32-generic", arch: "i386", family: "unix"
[INFO] Error stacktraces are turned on.
[DEBUG] Reading global settings from /usr/java/apache-maven-3.0.3/conf/settings.xml
[DEBUG] Reading user settings from /home/myhome/.m2/settings.xml
...

In this output, you can see that the settings.xml is loaded from /home/myhome/.m2/settings.xml.

ndeverge
  • 21,378
  • 4
  • 56
  • 85
  • I know this is an old post but I need some guidance. I ran the mvn -X on my system and I do not see a settings.xml listed anywhere. The output I see show Maven version 2.2.1 and user & global level plugin registry files from plugin-registry.xml. Why do I not have the settings.xml displayed and how do I get it to show? – edjm Sep 02 '15 at 14:16
  • 3
    @Elijah You should ask your own question. Reference this question in your new question. – reynoldsnlp Oct 02 '15 at 09:42
  • Very helpful. I was trying to specify "user settings" in `MAVEN_OPTS`, unfortunately this show that's not working. – will Nov 19 '18 at 23:13
  • 1
    Is it only my setup or is the message `Reading user settings from /home/myhome/.m2/settings.xml` only stating the *intention* to read from the file? I do get the same message after explicitly removing the file from the path. So what I get from the output is something like the effective search path for setting files but not the list of files that was actually read. – Marcus Rickert Apr 05 '22 at 09:30
13

mvn help:effective-settings shows the effective settings of the current environment including your location of settings.xml file.

Additionally showPasswords=true will help you see the passwords resolved as well if you are using environment variables.

mvn help:effective-settings -DshowPasswords=true

I had wasted a lot of time with -X option earlier and this will help you quickly solve your troubles.

Anand Varkey Philips
  • 1,811
  • 26
  • 41