Search code examples
javaeclipsemavenports

Ports and protocol used by Maven to download dependencies in Eclipse?


I'm on an enterprise working with eclipse as a programmer, and I have a project that works perfect at home. However, when I try to compile the pom.xml at work it says: "Failure to transfer org.apache.maven" and "connect time out". I think it is because the network firewall in the enterprise is very restrictive with the use of ports, possibly blocking the acces. Does anyone know which ports and protocol does maven use to configure itself and do the installation? Can those ports be manually changed?

Thank you very much!


Solution

  • To modify the url port you can do something like this in settings.xml:

     <repositories>
          <repository>
              <id>repoId</id>
              <url>http://url:port/remains</url>
              <releases>
                <enabled>true</enabled>
              </releases>
            </repository>
    </repositories>
    

    And to use a proxy in maven, you can also add modify your settings.xml:

    <settings>
      .
      .
      <proxies>
       <proxy>
          <id>example-proxy</id>
          <active>true</active>
          <protocol>http</protocol>
          <host>proxy.example.com</host>
          <port>8080</port>
          <username>proxyuser</username>
          <password>somepassword</password>
          <nonProxyHosts>www.google.com|*.example.com</nonProxyHosts>
        </proxy>
      </proxies>
      .
      .
    </settings>
    

    Adapt as needed.