146

Where is Maven's settings.xml located on Mac OS?

cellepo
  • 4,001
  • 2
  • 38
  • 57
cesarggf
  • 1,752
  • 2
  • 11
  • 10
  • 7
    "This is the configuration file for Maven. It can be specified at two levels: 1. `User Level`. This settings.xml file provides configuration for a single user, and is normally provided in `${user.home}/.m2/settings.xml`. 2. `Global Level`. This settings.xml file provides configuration for all Maven users on a machine (assuming they're all using the same Maven installation). It's normally provided in `${maven.home}/conf/settings.xml`." – Weishi Z May 24 '16 at 21:20
  • Hey, don't forget to accept an answer. –  Mar 02 '18 at 17:49

13 Answers13

175

If you use brew to install maven, then the settings file should be in

/usr/local/Cellar/maven/<version>/libexec/conf

Andy
  • 49,085
  • 60
  • 166
  • 233
Meng
  • 1,891
  • 1
  • 12
  • 10
90

It doesn't exist at first. You have to create it in your home folder, /Users/usename/.m2/ (or ~/.m2)

For example :

alt text

Colin Hebert
  • 91,525
  • 15
  • 160
  • 151
  • 4
    In the latest MAC OS X Maven is included so .m2 will be created automatically under the `/Users/username/.m2` – raksja Jul 20 '11 at 23:40
  • 6
    If anyone's wondering what to put in it, look here: http://maven.apache.org/settings.html – Graham Lea Nov 30 '11 at 03:48
  • 2
    As of Mavericks, Maven is not preinstalled. See [Maven not found in Mac OSX Mavericks](http://stackoverflow.com/questions/19678594/maven-not-found-in-mac-osx-mavericks) – karmakaze Nov 21 '13 at 21:39
44

if you install the maven with the brew

you can type the command("mvn -v") in Terminal

see Maven home detail

mvn -v
Apache Maven 3.5.0 (ff8f5e7444045639af65f6095c62210b5713f426; 2017-04-04T03:39:06+08:00)
Maven home: /usr/local/Cellar/maven/3.5.0/libexec
Java version: 1.8.0_121, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre
Default locale: zh_CN, platform encoding: UTF-8
OS name: "mac os x", version: "10.11.5", arch: "x86_64", family: "mac"
water_ak47
  • 1,174
  • 12
  • 9
11

I found it under /usr/share/java/maven-3.0.3/conf , 10.8.2

julian0zzx
  • 263
  • 2
  • 8
  • 2
    I created a symlink to it from ~/.m2: `ln -s /usr/share/maven/conf/settings.xml settings.xml` – craig Dec 03 '12 at 15:57
  • 1
    On my machine (10.8.2) the default /usr/share/java/maven-3.0.3/conf/settings.xml has everything commented out, so does nothing. Creating a new file in ~/.m2 is probably easiest. – Philip Callender Jan 06 '13 at 20:00
  • `/usr/share/java/maven-3.0.3` is the path for global settings, this is a different thing to user-settings; c.f. https://www.eviltester.com/2013/09/maven-settingsxml-global-and-user.html – Jakub Bochenski Jun 24 '19 at 14:34
4

->It is located in $MAVEN_HOME/conf/settings.xml... where $MAVEN_HOME is your environmental variable of Maven that you have downloaded. Else you can do like this also.. ->Path to Maven can also be found from /etc/bashrc file in mac. Get Path to Maven from that file and in that Maven directory you can find conf/ directory inside that directory you can find settings.xml of maven

chaitanya
  • 693
  • 2
  • 7
  • 16
2

found it under /Users/username/apache-maven-3.3.9/conf

Chen
  • 2,958
  • 5
  • 26
  • 45
2

I brew installed it, and found it under /usr/local/apache-maven-3.3.3/conf

ben26941
  • 1,580
  • 14
  • 20
2

For macOS Monterey 12.0.1 and home-brew 3.4.7, it locates at /opt/homebrew/Cellar/maven/{version}/libexec/

I got this location from mvn -version, which gives me

Apache Maven 3.8.5 (3599d3414f046de2324203b78ddcf9b5e4388aa0)
Maven home: /opt/homebrew/Cellar/maven/3.8.5/libexec
Java version: 18, vendor: Homebrew, runtime: /opt/homebrew/Cellar/openjdk/18/libexec/openjdk.jdk/Contents/Home
Default locale: en_SG, platform encoding: UTF-8
OS name: "mac os x", version: "12.0.1", arch: "aarch64", family: "mac"
1

After I have downloaded the binary from apache site I, have placed the extracted folder in /Library
So now the location of the settings.xml file is in:

/Library/apache_maven_3.6.3/conf
gregor vojvoda
  • 129
  • 1
  • 12
1

I think it's the best to use mvn -X so it should print you locations of settings being used effectively

...
[DEBUG] Reading global settings from /opt/homebrew/Cellar/maven/3.8.6/libexec/conf/settings.xml
[DEBUG] Reading user settings from /Users/XXX/.m2/settings.xml
...
Mariusz W.
  • 116
  • 3
0

I installed mavaen using sdkman because of which the other proposed solution didn't work, as they are applicable if the installation is done via Homebrew or as a standalone binary.

for my solution I did "which mvn" in the terminal which returned: "/Users/samkaz/.sdkman/candidates/maven/current/bin/mvn"

Then after opening the path in a finder and looking around the above directory I found settings.xml in the below folder. "/Users/samkaz/.sdkman/candidates/maven/3.6.3/conf"

Sam Kaz
  • 432
  • 3
  • 12
0

If you have installed maven with brew then it must be at the path

/usr/local/Cellar/maven/(mvn_version)/libexec/conf/settings.xml
logi-kal
  • 7,107
  • 6
  • 31
  • 43
0

To find out settings.xml

Use mvn -version then find out the Maven home path in the output of mvn -version for ex:

@AMAWQ5XV34HCJ conf % mvn -version
Apache Maven 3.9.0 (9b58d2bad23a66be161c4664ef21ce219c2c8584)
Maven home: /opt/homebrew/Cellar/maven/3.9.0/libexec
Java version: 17.0.4, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/backup/jdk-17.0.4.jdk/Contents/Home
Default locale: en_NO, platform encoding: ISO8859-1
OS name: "mac os x", version: "12.6.3", arch: "x86_64", family: "mac

settings.xml will be found at

<Mavenhome path>/conf

forex: /opt/homebrew/Cellar/maven/3.9.0/libexec/conf

Alternately you can also move to .m2 folder, which is ideally located in the root, of not create one and copy to that -m2

mkdir ~/.m2
cp /opt/homebrew/Cellar/maven/3.9.0/libexec/conf/settings.xml ~/.m2
Ramya Musunuru
  • 177
  • 1
  • 5