maven報錯:Return code is: 501 , ReasonPhrase:HTTPS Required
阿新 • • 發佈:2020-01-26
今天把一個去年沒做完的專案翻出來做時,發現maven無法正常匯入依賴。檢查了一遍專案配置,沒發現有什麼問題。而且依賴在本地倉庫存在。
隨後發現報錯:Failed to transfer file:*********. Return code is: 501 , ReasonPhrase:HTTPS Required. 這時候好像發現了什麼重點————我們需要將maven配置修改一下:
<!-- 中央倉庫1 --> <mirror> <id>repo1</id> <mirrorOf>central</mirrorOf> <name>Human Readable Name for this Mirror.</name> <url>https://repo1.maven.org/maven2/</url> </mirror> <!-- 中央倉庫2 --> <mirror> <id>repo2</id> <mirrorOf>central</mirrorOf> <name>Human Readable Name for this Mirror.</name> <url>https://repo2.maven.org/maven2/</url> </mirror>
隨後發現可以正常匯入依賴了。
在stackoverflow上查了下,發現有人也遇到了這個問題:
Recently Maven build jobs running in Jenkins are failing with the below exception saying that they could not pull dependencies from Maven Central and should use HTTPS. I am not sure how to change the requests from HTTP to HTTPS. Could someone guide me on this matter?
回答如下:
Effective January 15, 2020, The Central Repository no longer supports insecure communication over plain HTTP and requires that all requests to the repository are encrypted over HTTPS.
所以這個問題的根源就是maven中央倉庫現在只支援HTTPS協議,我們改一下就行。
&n