'Intellij is not able to fetch maven artifacts in private repository

At work we have no direct connection to the internet. To fetch maven artifacts we need to use a local Nexus, which mirrors all of maven-central. I have a settings.xml containing the needed configuration. (Hostname, password, etc.)

Running mvn from the command line works fine. (Both for fetching regular jars and sources.)

Intellij however is not able to fetch any artifacts. Looks like it uses the correct server, but maybe(?) does not authenticate.

I cannot see a helpful error message in intellij. However in my .m2/repository instead of the artifact I find a file *.jar.lastUpdated which says:

.../public-snapshots/.error=Could not transfer artifact ... from nexus (*Correct URL*):
Transfer failed for https://*correct URL*.jar

So it look like Intellij tried to fetch the file from the correct server, but was not able to do so.

Any idea what might be the problem here, or where I could find a more detailed error message?

(In the maven options of Intellij I already set the correct MAVEN_HOME and the correct settings.xml. According to the above message Intellij also read the settings file to replace the correct URL.)

Here is the requested settings dialog: intellij maven settings

Also running Maven explicitly using the lifecycle targets in Intellij works fine, but any internal features like "Download sources and documentation" fail.



Solution 1:[1]

I faced similar issues with maven repository and Intellij. What I found is under .idea directory there is jarRepositories.xml file which by default points to "Maven central repository" i.e., "https://repo1.maven.org/maven2". However, as we have organization specific maven repository under settings.xml, I noticed, Intellij tries to download repository from maven repository mentioned in jarRepositoris.xml and not that from Settings.xml. I verified this by executing "mvn clean install" from command prompt with building project from Intellij. Later when I changed jarRepositories.xml to point to organization specific maven repo, I was able to build project from Intellij as well.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Swapnil Shrishrimal