JavaGian java tutorial and java interview question and answer

JavaGian , Free Online Tutorials, JavaGian provides tutorials and interview questions of all technology like java tutorial, android, java frameworks, javascript, ajax, core java, sql, python, php, c language etc. for beginners and professionals.

Maven – Settings File

Maven settings.xml file contains configurations that are not specific to a project, but are global in nature. It also contains information that is not meant to be distributed (e.g. passwords).

Location of Maven Settings File

Maven can have two settings files working at a time:
  • The Maven installation directory: $M2_HOME/conf/settings.xml [global settings]
  • The user’s home directory: ${user.home}/.m2/settings.xml [user settings]
Both files are optional. If both files are present, the values in the user home settings file overrides the values from global settings file.

Maven Default setting.xml

A default maven setting.xml look like this:
      xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                          http://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 below table:
ELEMENT NAMEDESCRIPTION
localRepositoryMaven 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.
interactiveModeAs the name suggests, when this value is set to true, the default value, Maven interacts with the user for input.
usePluginRegistryIt decide that if Maven should use the ${user.home}/.m2/plugin-registry.xml file to manage plugin versions. Its default value is false.
offlineWhen set to true, this configuration instructs Maven to operate in an offline mode. The default is false.
pluginGroupsIt contains a list of pluginGroup elements, each contains 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.
serversMaven 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.
mirrorsAs the name suggests, mirrors allow you to specify alternate locations for your repositories.
proxiesproxies contains the HTTP proxy information needed to connect to the Internet.
profilesprofiles allow you to group certain configuration elements, such as repositories and pluginRepositories.
activeProfileThe activeProfile allows you to specify a default profile to be active for Maven to use.

.