Maven settings.xml
file contains global configurations that are not specific to a project. It also contains secure information that is not meant to be distributed (e.g. passwords).
1. Location of Maven Settings File
Maven can have two settings files working at a time:
- Maven installation directory:
$M2_HOME/conf/settings.xml
[Global settings file] - User’s home directory:
${user.home}/.m2/settings.xml
[User settings file]
Both files are optional. If both files are present, the values in the user home settings file override the values from the global settings file.
2. Maven Default setting.xml
A default maven setting.xml
look like this:
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
https://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository/>
<interactiveMode/>
<usePluginRegistry/>
<offline/>
<pluginGroups/>
<servers/>
<mirrors/>
<proxies/>
<profiles/>
<activeProfiles/>
</settings>
A brief description of the elements is given in the below table, Read about their detailed usage in Maven documentation.
Element Name | Description |
---|---|
localRepository | Maven stores copies of plug-ins and dependencies locally in the C:\Users\<your_user_name>\.m2\repository folder. This element can be used to change the path of the local repository. |
interactiveMode | As the name suggests, when this value is set to true , the default value, Maven interacts with the user for input. |
usePluginRegistry | It decides that if Maven should use the ${user.home}/.m2/plugin-registry.xml file to manage plugin versions. Its default value is false . |
offline | When set to true , this configuration instructs Maven to operate in an offline mode. The default is false . |
pluginGroups | It contains a list of pluginGroup elements, each containing a groupId . The list is searched when a plugin is used and the groupId is not provided in the command line. This list automatically contains org.apache.maven.plugins and org.codehaus.mojo . |
servers | Maven can interact with a variety of servers, such as Apache Subversion (SVN) servers, build servers, and remote repository servers. This element allows you to specify security credentials, such as the username and password, which you need to connect to those servers. |
mirrors | As the name suggests, mirrors allow you to specify alternate locations for your repositories. |
proxies | proxies contain the HTTP proxy information needed to connect to the Internet. |
profiles | profiles allow you to group certain configuration elements, such as repositories and pluginRepositories . |
activeProfile | The activeProfile allows you to specify a default profile to be active for Maven to use. |
Drop me your questions in the comments section.
Happy Learning !!