Talking about settings.xml file in Apache Maven – Part 1

The settings.xml file is the Apache Maven configuration file, which defines how Apache Maven will execute to handle dependencies when we use these dependencies in Maven projects. Instead of defining the configuration information in the pom.xml file for each Maven project, we can use the settings.xml file to do this, and then the Maven project will only reuse this configuration information. I will talk about the settings.xml file in Apache Maven in this tutorial for you all to understand more about it.

The first thing I will say about the location of this file.

By default, when you download the Apache Maven installation file and extract the file, the settings.xml file will default to the conf folder in the Apache Maven installation directory.

Talking about settings.xml file in Apache Maven - Part 1

Another location of this settings.xml file is located in the .m2 directory in the user directory.

Talking about settings.xml file in Apache Maven - Part 1

If you have two settings.xml files located in the two folders above then the configuration in these two files will be merged with each other. For general configurations, the settings in the settings.xml file in the user directory will have higher priority.

Next, I’ll talk about the contents of the settings.xml file.

If you open the settings.xml file located in the conf folder of the Apache Maven installation directory, you will see that the contents of this file include a <settings> root tag and some child tags, such as:

In there, the <localRepository />, <interactiveMode />, <offline /> tags are the tags that will be configured with simple values.

The <localRepository /> tag is used to specify the location of the Maven Local Repository, the default location pointing to the .m2/repository directory located in the user directory. You can change this location if you want.

The <interactiveMode /> tag allows Apache Maven to directly interact with input from the user. The default value of this tag is true, which means that it allows you to.

The <offline /> tag refers to whether Apache Maven works with offline mode. Often we will use this mode in case Apache Maven cannot connect to the remote repositories. Then, the value of this tag will be true, by default, the value of this tag is false.

The <pluginGroups /> tag will contain a list of <pluginGroup> tags, used to configure the groupId for the plugins we will use in our Maven projects, for example:

The <proxies /> tag is used in case you need to use a proxy to download dependencies.


We can declare more proxies in this <proxies> tag, each of which will be indentify by the <id> tag. You can specify which proxy is active with the <active> tag. As you can see, we will declare proxy information using the <protocol>, <host>, <port>, <username>, <password> tags. For connections that do not need to use a proxy, you use the <nonProxyHosts> tag to exclude them.

Chia sẽ bài viết này ...Share on Facebook
0Tweet about this on Twitter
Share on LinkedIn

Add Comment