Friday, December 30, 2011

Issues in configuring settings.xml in maven

maven settings.xml configuration

As you know, Maven is a build tool for software java projects. Most of the developers have used maven over ant these days because of maven resolve their dependencies.

maven settings configuration

It is a settings.xml file used to configure environment specific settings such as repositories(Local and remote repositories) and proxy configuration and server credentials. These settings are specific to the user where Maven is configured.
The default location on your machine is ~/.m2/settings.xml

what is a repository in Maven:-

As you know, in a java application, there are a lot of dependencies such as log4j, Apache libraries. These are called dependencies to your project. you have to define all your dependencies in pom.xml.

These libraries are available in apache repositories. so you have to download all these files when we don't use maven in your project.
If we have used maven to your project, these libraries(jar files) are downloaded to your local repository for the first to your company host.

The local repository contains java libraries downloaded from different libraries repositories.

Settings.xml sample file

<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
                      http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <proxies>
    <proxy>
      <id>userspecificproxy</id>
      <active>true</active>
      <protocol>http</protocol>
      <host>proxy.com</host>
      <port>8080</port>
      <username>usernameofproxy</username>
      <password>passwordofproxy</password>
      <nonProxyHosts>configure here</nonProxyHosts>
    </proxy>
  </proxies>
</settings>
This settings.xml is created in your {user's m2 folder}/.m2/settings.xml by default.

Related article


EmoticonEmoticon