Home >Java >javaTutorial >How to Fix '501: HTTPS Required' Errors in Maven Builds?

How to Fix '501: HTTPS Required' Errors in Maven Builds?

Susan Sarandon
Susan SarandonOriginal
2024-12-13 09:33:22313browse

How to Fix

HTTP to HTTPS Migration for Maven Dependencies

Maven builds integrated with Jenkins are encountering a "501: HTTPS Required" error when accessing dependencies from Maven Central. This error stems from Maven Central discontinuing support for plain HTTP communication and requiring the use of HTTPS.

Cause of the Error

As of January 15, 2020, Maven Central requires all requests to be encrypted over HTTPS. This means that Maven builds using HTTP protocol will fail to retrieve dependencies.

Solution

To resolve this issue, it is necessary to migrate your Maven builds to use HTTPS. Here are the steps to do so:

  1. Check the Maven version used in your builds. If you are using Maven 3.6.0 or higher, it should automatically use HTTPS.
  2. For older versions of Maven, you will need to manually update the repository URL to use HTTPS. In your pom.xml, replace "http://repo.maven.apache.org/maven2" with "https://repo.maven.apache.org/maven2".

Timeline for Repository Switching

  • Maven Central: Switched to HTTPS on January 13th, 2020.
  • JCenter: Switched to HTTPS on May 1st, 2020.
  • Sonatype Nexus Repository Manager: Switched to HTTPS on September 30th, 2020.

It is recommended to update your Maven configurations as soon as possible to ensure uninterrupted dependency fetching.

The above is the detailed content of How to Fix '501: HTTPS Required' Errors in Maven Builds?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn