Blog
How to download maven dependencies behind organization proxy
A quick guide on how to download Maven dependencies behind your organization’s proxy.
Introduction#
Whether you’re a Software Developer or an Automation Engineer, Maven is a widely used build tool today. One common challenge in some environments is the inability to download Maven dependencies due to organizational proxies. In this article, I’ll share a quick guide on how to download Maven dependencies behind your organization’s proxy.
Proxy Configuration#
Let’s understand how to setup proxy configuration. This configuration can be done in settings.xml file.
- Open your settings.xml file located in
<user_home>/.m2directory. If the file does not exist, you can create it. - Add the following
<proxies>configuration inside the<settings>element, replacing proxy.example.com and 8080 with your server’s hostname and port:
<proxies>
<proxy>
<id>example-proxy</id>
<active>true</active>
<protocol>http</protocol>
<host>proxy.example.com</host>
<port>8080</port>
<!-- Optional: Proxy username and password -->
<!--<username>proxy-username</username>-->
<!--<password>proxy-password</password>-->
<!--<nonProxyHosts>localhost|127.0.0.1</nonProxyHosts>-->
</proxy>
</proxies>plaintextIf your organization requires authentication, uncomment the <username> and <password> tags and provide your credentials. Additionally, you can specify hosts that should bypass the proxy in the <nonProxyHosts> tag.
Test the Configuration:#
To test the proxy configuration, run a Maven command such as mvn clean install for a Maven project. Maven should now be able to download dependencies through the proxy.
Related posts
Java Spring Boot Docker Deployment with Oracle Made Simple
Learn how to setup docker deployment of your Java Spring Boot application including Oracle Database dependency easily.
Instrument JaCoCo Code Coverage agent with WebLogic
Learn how to instrument JaCoCo code coverage agent with WebLogic server.
JaCoCo Code Coverage Setup with Maven
Step-by-step guide to integrate JaCoCo code coverage tool with Maven for measuring and improving test coverage in Java projects.