FaqMavenProxySettings

Revision as of 16:58, 30 August 2011 by Jglick (Talk | contribs)

How do I specify Maven proxy settings?

If you see output similar to the following when trying to create a Maven project, it might mean that Maven is having problems connecting to Maven repositories because of proxy settings.

Build failed.
Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.0:generate 
(default-cli) on project standalone-pom: The desired archetype does not exist
(org.codehaus.mojo.archetypes:webapp-javaee6:1.4) -> [Help 1]


Starting with NetBeans IDE 6.9, you do not need a separate installation of Maven because Maven is bundled with the IDE. When you install the IDE, Maven is installed in the netbeans.home/java/maven/ directory, where netbeans.home is the location of your NetBeans IDE installation. When you create or build a Maven project, the bundled Maven will create a local repository for you in the default location (${user.home}/.m2) if a local repository does not exist.

Maven needs to be able to access various Maven repositories in order to download artifacts to the local repository. If your local system is accessing the Internet through a proxy host, you might need to explicitly specify the proxy settings for Maven by editing the Maven settings.xml file. The bundled Maven installation ignores the IDE proxy settings that are set in the Options window.

For many common cases, just passing -Djava.net.useSystemProxies=true to Maven should suffice to download artifacts through the system's configured proxy. NetBeans 7.1 will offer to configure this flag for you if it detects a possible proxy problem. https://netbeans.org/bugzilla/show_bug.cgi?id=194916 has discussion.

Locating the Maven settings.xml file

Proxy settings for Maven are specified in the settings.xml file. There are two possible locations for the settings.xml file.

  • netbeans.home/java/maven/conf/settings.xml. This file is located in the Maven installation that is bundled with the IDE. This file contains the global settings for the Maven installation.
  • user.home/.m2/settings.xml. This file is located in your local repository and contains the user settings for users of the local repository. If the local repository does not contain a settings.xml file you can copy the global settings file from the Maven installation location.

Setting the proxy in the Maven settings.xml file

You will probably want to specify the proxy settings in the settings.xml file (user settings) in your local repository. Any changes that you make to the settings.xml file in the Maven installation (global settings) will be lost if you reinstall or install a newer version of the IDE.

  1. Open the settings.xml in your editor.
  2. Locate the <proxies> element in the file.
<proxies>
    <!-- proxy
     | Specification for one proxy, to be used in connecting to the network.
     |
    <proxy>
      <id>optional</id>
      <active>true</active>
      <protocol>http</protocol>
      <username>proxyuser</username>
      <password>proxypass</password>
      <host>proxy.host.net</host>
      <port>80</port>
      <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
    </proxy>
    -->
  </proxies>
  1. Uncomment the proxy setting elements and specify the settings for your proxy host.
<proxies>
   <proxy>
   <active>true</active>
   <host>myproxy.host.net</host>
     <port>80</port>
   </proxy>
 </proxies>
  1. Save your changes.


For more about the Maven settings.xml file, see http://maven.apache.org/settings.html#Proxies

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo