MeWrite Docs

Could not transfer artifact

Mavenでアーティファクトの転送に失敗した場合に発生するエラー

概要

Could not transfer artifact は、Mavenがリモートリポジトリからアーティファクト(JAR、POM等)をダウンロードできない場合に発生するエラーです。ネットワーク接続、プロキシ設定、リポジトリ認証の問題が主な原因です。

エラーメッセージ

[ERROR] Could not transfer artifact org.springframework:spring-core:jar:6.1.0
from/to central (https://repo.maven.apache.org/maven2):
Transfer failed for https://repo.maven.apache.org/maven2/org/springframework/spring-core/6.1.0/spring-core-6.1.0.jar
[ERROR] Could not transfer artifact from/to central:
Connect to repo.maven.apache.org:443 failed: Connection timed out
[ERROR] Could not transfer artifact: 501 HTTPS Required

原因

1. ネットワーク接続の問題

ファイアウォール、VPN、またはネットワーク障害によりMaven Centralにアクセスできない場合があります。

2. プロキシ設定の不備

企業ネットワーク内でプロキシ経由のアクセスが必要な場合、settings.xmlにプロキシ設定が必要です。

3. HTTPS必須化への未対応

Maven Central は2020年1月よりHTTPS必須です。古い http:// URLを使用しているとエラーになります。

4. リポジトリ認証の失敗

プライベートリポジトリへのアクセスに認証情報が不足している場合があります。

解決策

1. ネットワーク接続を確認

1
2
3
4
5
# Maven Centralへの接続テスト
curl -I https://repo.maven.apache.org/maven2

# DNS解決の確認
nslookup repo.maven.apache.org

2. プロキシ設定を追加

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
<!-- ~/.m2/settings.xml -->
<settings>
    <proxies>
        <proxy>
            <id>https-proxy</id>
            <active>true</active>
            <protocol>https</protocol>
            <host>proxy.example.com</host>
            <port>8080</port>
            <nonProxyHosts>localhost|127.0.0.1</nonProxyHosts>
        </proxy>
    </proxies>
</settings>

3. HTTPSリポジトリURLを使用

1
2
3
4
5
6
7
<!-- pom.xml - HTTP を HTTPS に変更 -->
<repositories>
    <repository>
        <id>central</id>
        <url>https://repo.maven.apache.org/maven2</url> <!-- https:// を使用 -->
    </repository>
</repositories>

4. リポジトリ認証を設定

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
<!-- ~/.m2/settings.xml -->
<settings>
    <servers>
        <server>
            <id>my-private-repo</id>
            <username>deploy-user</username>
            <password>deploy-password</password>
        </server>
    </servers>
</settings>

5. ミラーリポジトリを設定

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
<!-- ~/.m2/settings.xml -->
<settings>
    <mirrors>
        <mirror>
            <id>aliyun</id>
            <mirrorOf>central</mirrorOf>
            <url>https://maven.aliyun.com/repository/public</url>
        </mirror>
    </mirrors>
</settings>

6. タイムアウト設定を調整

1
2
# タイムアウトを延長してビルド
mvn clean install -Dmaven.wagon.http.connectionTimeout=60000 -Dmaven.wagon.http.readTimeout=60000

デバッグ方法

1
2
3
4
5
# 詳細なデバッグ出力でネットワーク問題を特定
mvn clean install -X

# 有効なsettings.xmlを表示
mvn help:effective-settings

関連エラー

関連エラー

Java の他のエラー

最終更新: 2026-02-12