{"id":1162,"date":"2026-12-05T22:31:29","date_gmt":"2026-12-05T20:31:29","guid":{"rendered":"https:\/\/mexela.com\/blog\/maven-proxy-settings\/"},"modified":"2026-12-05T22:48:11","modified_gmt":"2026-12-05T20:48:11","slug":"maven-proxy-settings","status":"publish","type":"post","link":"https:\/\/mexela.com\/blog\/maven-proxy-settings\/","title":{"rendered":"Maven Proxy Setup: Fix Dependency Downloads Behind a Proxy"},"content":{"rendered":"<p>If Maven cannot resolve a dependency but your Java app runs correctly, check Maven\u2019s network settings first. Artifact downloads happen during the build. They do not inherit client-specific proxy settings from the Java application that the build produces.<\/p>\n<h2 id=\"maven-config\">Put the proxy in your Maven settings<\/h2>\n<p>Use a separate user settings file for the first check. Replace the example hostname and port with your approved proxy. The pipe-separated <code>nonProxyHosts<\/code> patterns are examples; keep only hosts that your organization explicitly allows to be contacted directly. A private Maven mirror is not automatically an exception. See <a href=\"https:\/\/maven.apache.org\/guides\/mini\/guide-proxies.html\">Apache Maven\u2019s proxy guide<\/a>.<\/p>\n<pre id=\"maven-settings\"><code class=\"language-xml\">&lt;settings xmlns=\"http:\/\/maven.apache.org\/SETTINGS\/1.2.0\"&gt;\n  &lt;proxies&gt;\n    &lt;proxy&gt;\n      &lt;id&gt;corporate&lt;\/id&gt;\n      &lt;active&gt;true&lt;\/active&gt;\n      &lt;protocol&gt;http&lt;\/protocol&gt;\n      &lt;host&gt;proxy.example.com&lt;\/host&gt;\n      &lt;port&gt;3128&lt;\/port&gt;\n      &lt;nonProxyHosts&gt;localhost|127.0.0.1|*.example.internal&lt;\/nonProxyHosts&gt;\n    &lt;\/proxy&gt;\n  &lt;\/proxies&gt;\n&lt;\/settings&gt;<\/code><\/pre>\n<p>Keep secrets out of shared project files. Proxy credentials authenticate to the network intermediary; Maven repository credentials authenticate to the mirror or registry and belong under the matching server ID in your settings. Use the credential mechanism approved for your installed Maven version.<\/p>\n<h2 id=\"maven-fresh-repo\">Test resolution without a warm Maven cache<\/h2>\n<p>From a small, approved Maven project in PowerShell, set <code>MEXELA_MAVEN_SETTINGS<\/code> to the test settings file and <code>MEXELA_MAVEN_CACHE<\/code> to a new disposable repository directory you control. Choose a project whose parent POM must be fetched and has no local relative parent. An empty project might reach <code>validate<\/code> without downloading anything.<\/p>\n<pre id=\"maven-build\"><code class=\"language-powershell\">mvn -s \"$env:MEXELA_MAVEN_SETTINGS\" \"-Dmaven.repo.local=$env:MEXELA_MAVEN_CACHE\" -B validate<\/code><\/pre>\n<p>Look for the expected parent artifact in the new cache and, where available, confirm the request in an approved proxy log. Avoid sharing raw debug output that might contain paths, hostnames or credentials.<\/p>\n<h2 id=\"maven-errors\">Separate proxy, repository and Java trust errors<\/h2>\n<table>\n<thead>\n<tr>\n<th>Build error<\/th>\n<th>What to inspect<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>407<\/td>\n<td>The corporate proxy\u2019s authentication policy.<\/td>\n<\/tr>\n<tr>\n<td>401 or 403 from the mirror<\/td>\n<td>The repository account, permissions, mirror ID and server settings.<\/td>\n<\/tr>\n<tr>\n<td>PKIX or certificate error<\/td>\n<td>The trust store of the JDK Maven is actually running. Use approved CA material; do not disable certificate validation.<\/td>\n<\/tr>\n<tr>\n<td>Artifact not found<\/td>\n<td>Coordinates, version, selected mirror and repository policy.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>If requests from the finished Java app fail instead, use the <a href=\"\/blog\/java-httpclient-okhttp-proxy\/\">Java HttpClient and OkHttp guide<\/a>. Both articles are part of the <a href=\"\/blog\/proxy-setup-developer-guides\/\">developer integration hub<\/a>.<\/p>\n<p><strong>Verification, December 5, 2026:<\/strong> Apache Maven 3.10.2 read the displayed settings structure and resolved a fixture parent POM through a loopback proxy into a new local cache. A separate empty-cache build failed when the proxy returned 407. The disposable lab changed only the template host and port; it did not contact Maven Central.<\/p>\n<p><!-- mexela-semrush-maven-runner-settings-diagnostic-20261206:start --><\/p>\n<section aria-labelledby=\"maven-ide-and-runner-settings\">\n<h2 id=\"maven-ide-and-runner-settings\">Why does Maven work locally but fail in an IDE or CI?<\/h2>\n<p>Compare the Maven distribution, Java runtime, and user settings file selected by each launcher. Run <code>mvn -version<\/code> in the environment where the build fails, or inspect the IDE\u2019s Maven runner settings if the IDE starts Maven itself. Check for an explicit <code>-s<\/code> file and verify which global and user settings the build uses. They are merged according to the <a href=\"https:\/\/maven.apache.org\/settings.html\">Maven settings reference<\/a>.<\/p>\n<p>Repeat the small dependency-resolution check with the same parent artifact, the intended settings file, and a fresh disposable local repository. Capture the selected mirror, Maven and Java versions, and the first error with secrets removed. This comparison can reveal a different mirror or Java trust store that a warm local cache concealed.<\/p>\n<\/section>\n<p><!-- mexela-semrush-maven-runner-settings-diagnostic-20261206:end --><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Configure an approved Maven proxy in settings.xml and test dependency access with an isolated repository. Distinguish proxy, TLS and registry failures.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[189],"tags":[],"_links":{"self":[{"href":"https:\/\/mexela.com\/blog\/wp-json\/wp\/v2\/posts\/1162"}],"collection":[{"href":"https:\/\/mexela.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mexela.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mexela.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mexela.com\/blog\/wp-json\/wp\/v2\/comments?post=1162"}],"version-history":[{"count":0,"href":"https:\/\/mexela.com\/blog\/wp-json\/wp\/v2\/posts\/1162\/revisions"}],"wp:attachment":[{"href":"https:\/\/mexela.com\/blog\/wp-json\/wp\/v2\/media?parent=1162"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mexela.com\/blog\/wp-json\/wp\/v2\/categories?post=1162"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mexela.com\/blog\/wp-json\/wp\/v2\/tags?post=1162"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}