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]

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. Maven builds ignore 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; you should not edit it.
  • user.home/.m2/settings.xml. This file is located next to 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 user ~/.m2/settings.xml. 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.
    <!-- proxy
     | Specification for one proxy, to be used in connecting to the network.
  1. Uncomment the proxy setting elements and specify the settings for your proxy host.
  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