Mavenインストールが失敗するようになった

SpiringBootで作成中のツールにちょっと機能が漏れていたので、pom.xmlにライブラリを追加したところ、ダウンロード出来ませんとの事。

[INFO] Scanning for projects...
[INFO] 
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building api-tool 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] Downloading: http://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-starter-security/2.0.1.RELEASE/spring-boot-starter-security-2.0.1.RELEASE.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.814 s
[INFO] Finished at: 2020-01-29T10:56:41+09:00
[INFO] Final Memory: 15M/159M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project api-tool: Could not resolve dependencies for project api-tool:api-tool:jar:0.0.1-SNAPSHOT: Failed to collect dependencies at org.springframework.boot:spring-boot-starter-security:jar:2.0.1.RELEASE: Failed to read artifact descriptor for org.springframework.boot:spring-boot-starter-security:jar:2.0.1.RELEASE: Could not transfer artifact org.springframework.boot:spring-boot-starter-security:pom:2.0.1.RELEASE from/to central (http://repo.maven.apache.org/maven2): Failed to transfer http://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-starter-security/2.0.1.RELEASE/spring-boot-starter-security-2.0.1.RELEASE.pom. Error code 501, HTTPS Required -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException

mavenリポジトリから501が応答されているのですが、何か変わったのでしょうか?
試しに、ブラウザ越しに上記のDownload URLをたたくと下記の応答

501 HTTPS Required.
Use https://repo.maven.apache.org/maven2/
More information at https://links.sonatype.com/central/501-https-required

httpsにしなくちゃいけないって事?

ちょっと調べると下記を発見。
[blogcard url=”https://arimodoki.mydns.jp/promenade/s_mavenpom.html”]

今時当たり前なのですが、Mavenリポジトリがhttpsのみに変わったようです。

Mavenツールが古いからかな?とまずeclipse(marsを今でも使用中)から更新の確認を実行してもダメ。
インストールの詳細からm2e Eclipse用Maven統合 を更新してもダメでした。

上記リンクに、pom.xmlで設定するのは例が書かれていますので、有難くこれで一旦解決には出来ますが、プロジェクト個別設定でなくて全体的にどうにかならないの?と、.m2に置いてあるsetting.xmlの設定で対応してみます。

結果、リポジトリ設定ではうまくいかず、ミラーの設定をしてみると、ちゃんとライブラリをダウンロードしてくれるようになりましたが、
初回はミラーから全てのライブラリをダウンロードしようとするようなので、とりあえずはpom.xmlで個別に対応した方がいいかもしれません。

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <mirrors>
    <mirror>
      <id>repo.maven.apache.org</id>
      <name>https maven2 </name>
      <url>https://repo.maven.apache.org/maven2</url>
      <mirrorOf>central</mirrorOf>
    </mirror>
  </mirrors> 
</settings>

後日、別環境で使っているeclipseで確認したところ、比較的新しいeclipseでは特に問題が無かったようです。どうやら、古いバージョンのeclipseだけ対応出来ないようです。

カテゴリー: Java