Maven Dependencies Fail with 501 Error
Recent Maven build jobs in Jenkins have encountered failures due to the following exception:
[ERROR] Failed to transfer artifact org.apache.maven.wagon:wagon-ssh:pom:2.1 from/to central (http://repo.maven.apache.org/maven2): Failed to transfer file: http://repo.maven.apache.org/maven2/org/apache/maven/wagon/wagon-ssh/2.1/wagon-ssh-2.1.pom. Return code is: 501 , ReasonPhrase:HTTPS Required.
This error indicates that Maven is attempting to retrieve dependencies from Maven Central using HTTP, which is no longer supported.
Solution
As of January 15, 2020, Maven Central requires HTTPS for all requests. To resolve the issue, ensure that your Maven settings use the HTTPS URL for Maven Central:
<settings> <profiles> <profile> <id>central-https</id> <repositories> <repository> <id>central</id> <url>https://repo.maven.apache.org/maven2</url> </repository> </repositories> </profile> </profiles> </settings>
Activate the "central-https" profile when running Maven commands, for example:
mvn -P central-https package
Additionally, ensure that the latest version of Maven (at least 3.6.0) is being used, as it includes updated default settings for HTTPS usage.
The above is the detailed content of Why Do My Maven Dependencies Fail with a 501 Error?. For more information, please follow other related articles on the PHP Chinese website!