Nexus won't download artifacts from Central

2020-04-15 20:46发布

问题:

I've just installed Nexus 2.2-01 behind a corporate proxy. Maven is working when I go direct to the Central repo, but when I configure the <mirror> in %M2_HOME%\conf\settings.xml I can't do a simple mvn archetype:create or mvn clean.

From the Nexus web UI I can:

  • "Browse Remote" in Central.
  • "Browse Index"
  • and from the "Artifact Information" tab where it says "(Not Locally Cached)" I can download the jars
  • and then see the .jar and .jar.sha1 files at "http://127.0.0.1:8081/nexus/content/groups/public/" and "\nexus\sonatype-work\nexus\storage\central"

...but for some reason it does not download the .pom files

Nexus 2.2 came with a proxy repository for Central pre-configured, and I can browse the index and download files manually from the web UI - so why won't it work from Maven?

I have configured Nexus with Default HTTP Proxy Settings with Authentication, but still get errors such as:

[ERROR] Plugin org.apache.maven.plugins:maven-clean-plugin:2.4.1 
  or one of its dependencies could not be resolved: 
  Failed to read artifact descriptor for org.apache.maven.plugins:maven-clean-plugin:jar:2.4.1: 
  Could not transfer artifact org.apache.maven.plugins:maven-clean-plugin:pom:2.4.1 from/to nexus 
  (http://myserver:8081/nexus/content/groups/public): 
  Failed to transfer file: 
  http://myserver:8081/nexus/content/groups/public/
  org/apache/maven/plugins/maven-clean-plugin/2.4.1/maven-clean-plugin-2.4.1.pom. 
  Return code is: 504, ReasonPhrase:Gateway Timeout. -> [Help 1]

and

[INFO] Scanning for projects...
Downloading: http://myserver:8081/nexus/content/groups/public/
  org/apache/maven/plugins/maven-clean-plugin/2.4.1/maven-clean-plugin-2.4.1.pom
[WARNING] Failed to retrieve plugin descriptor for 
  org.apache.maven.plugins:maven-clean-plugin:2.4.1: 
  Plugin org.apache.maven.plugins:maven-clean-plugin:2.4.1 
  or one of its dependencies could not be resolved: 
  Failed to read artifact descriptor for 
  org.apache.maven.plugins:maven-clean-plugin:jar:2.4.1
Downloading: http://myserver:8081/nexus/content/groups/public/
  org/codehaus/mojo/maven-metadata.xml
Downloading: http://myserver:8081/nexus/content/groups/public/
  org/apache/maven/plugins/maven-metadata.xml
[WARNING] Could not transfer metadata org.apache.maven.plugins/maven-metadata.xml
  from/to nexus (http://myserver:8081/nexus/content/groups/public): 
  Failed to transfer file: http://myserver:8081/nexus/content/groups/public/org/
  apache/maven/plugins/maven-metadata.xml. 
  Return code is: 504, ReasonPhrase:Gateway Timeout.

回答1:

Argh! DNS issue - using the IP address in the maven settings.xml fixed the problem.



回答2:

The other answer is correct, but just a note for people who get here with the same problem but the above answer doesn't help: Check your settings.xml proxy settings.



回答3:

I've seen this error today and the only thing that fixed it was going back to maven 3.2.5 (from 3.3.9)



回答4:

For this it seems that either

  1. the proxy section in your settings.xml is causing an issue (you should remove them or fix them)
  2. URL issue in your maven settings.xml

If the urls are correctly defined in there, possibly you need to open the hosts file in C:\Windows\System32\drivers\etc and map the server you are connecting to its corresponding IP... by adding a line that looks like this:

11.111.11.11 RepoUrl

this way you are declaring that the baseurl with name RepoUrl is actually the ip 11.1....