Maven Proxy Settings

Maven need to be configured with proxy settings if you are running maven behind firewall in corporate companies. How to configured proxy in maven using eclipse.

 

Eclipse Maven Proxy Settings: 

  • Click on Window -> Preferences -> Maven -> User Settings in eclipse
  • We can configure this is Global settings also if you want to use this for all POM
  • Create file settings.xml file in  USER_HOME\.m2 directory if not exist.
  • Maven Proxy

Copy the below proxies in settings.xml file

maven settings.xml

<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">
 
 <proxies>
      <proxy>
           <id>myproxy</id>
           <active>true</active>
           <protocol>http</protocol>
           <host>proxy.test.com</host>
           <port>8080</port>
           <username>corp\username</username>
           <password>Password</password>
            <nonProxyHosts>*.google.com|ibiblio.org</nonProxyHosts>
      </proxy>
 </proxies>
 </settings>

There are other configurations we can configure in settings.xml 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
 https://maven.apache.org/xsd/settings-1.0.0.xsd">
 <localRepository>${user.home}/.m2/repository</localRepository>
 <interactiveMode>true</interactiveMode>
 <usePluginRegistry>false</usePluginRegistry>
 <offline>false</offline>
 <servers>
 <server>
 <id>Server _ID</id>
 <username>jayaram</username>
 <password>test</password>
 <filePermissions>664</filePermissions>
 <directoryPermissions>775</directoryPermissions>
 <configuration></configuration>
 </server>
 </servers>
 ...
 <mirrors/>
 <proxies/>
 <profiles>
 <profile>
 <repositories>
 <repository>
 <url>http://repo1.maven.org/maven2</url>
 </repository>
 </repositories>
 <pluginRepositories>
 
 </pluginRepositories>
 ...
 </profile>
 </profiles>
 <activeProfiles/>
</settings>
  •  set offline to true if maven to run in localmode and not to connect server”
  • localRepository :  Set the custom maven repository here  if it is  different from default maven repository USER_HOME/.m2/repository
  • servers –  In pom.xml we can configure repositories to configure and repository credentials will be configured in settings.xml file
  • profiles – we can configure repositories under profile section

 

 

Leave a Comment

Your email address will not be published. Required fields are marked *