Set proxy for Maven

Sometimes, your Maven needs proxy to download object:

[INFO] Scanning for projects...
Downloading: http://repo.maven.apache.org/maven2/org/apache/apache/11/apache-11.pom
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR]   The project org.apache.mesos:mesos:0.25.0 (/home/nan/mesos-0.25.0/build/src/java/mesos.pom) has 1 error
[ERROR]     Non-resolvable parent POM: Could not transfer artifact org.apache:apache:pom:11 from/to central (http://repo.maven.apache.org/maven2): Connection to http://repo.maven.apache.org refused and 'parent.relativePath' points at wrong local POM @ line 18, column 11: Connection timed out -> [Help 2]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/UnresolvableModelException

The method is configuring proxy setting in ${HOME}/.m2/settings.xml:

$ echo ${HOME}
/home/nan
$ cat ${HOME}/.m2/settings.xml
<settings>
        <proxies>
                <proxy>
                        <active>true</active>
                        <protocol>http</protocol>
                        <host>web-proxy.xxxxxx.com</host>
                        <port>8080</port>
                </proxy>
        </proxies>
</settings>

Then it can work!

P.S. My Maven version is 3.0.5.

 

7 thoughts on “Set proxy for Maven”

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.