MeWrite Docs

Resolution will not be reattempted

Mavenで過去の解決失敗がキャッシュされ、再試行されない場合のエラー

概要

resolution will not be reattempted は、Mavenが過去に依存関係の解決に失敗した結果をローカルリポジトリにキャッシュし、デフォルトの更新間隔(24時間)が経過するまで再試行しない場合に表示されるエラーです。

エラーメッセージ

[ERROR] Failed to execute goal on project my-app: Could not resolve dependencies:
Could not find artifact com.example:my-library:jar:1.0.0 in central
(https://repo.maven.apache.org/maven2):
Failure to find com.example:my-library:jar:1.0.0 in https://repo.maven.apache.org/maven2
was cached in the local repository, resolution will not be reattempted until the update
interval of central has elapsed or updates are forced

原因

1. 一時的なネットワーク障害後のキャッシュ

ネットワーク切断時のビルド失敗がキャッシュされ、復旧後もエラーが継続する場合があります。

2. デプロイ前の依存関係参照

まだデプロイされていないアーティファクトを参照してビルドした失敗がキャッシュされている場合です。

3. リポジトリURLの変更後

リポジトリの移行やURL変更があった後、古い失敗情報がキャッシュに残っている場合があります。

解決策

1. 強制更新(-U オプション)

1
2
# SNAPSHOT・失敗キャッシュを強制更新
mvn clean install -U

2. .lastUpdated ファイルを削除

1
2
3
4
5
# 失敗キャッシュファイルを検索・削除
find ~/.m2/repository -name "*.lastUpdated" -delete

# 特定のアーティファクトのキャッシュを削除
rm -rf ~/.m2/repository/com/example/my-library

3. _remote.repositories ファイルを削除

1
2
# リポジトリ追跡ファイルを削除
find ~/.m2/repository -name "_remote.repositories" -delete

4. dependency:purge-local-repository を使用

1
2
3
4
5
# 指定した依存関係をローカルリポジトリから削除・再ダウンロード
mvn dependency:purge-local-repository -DmanualInclude=com.example:my-library

# すべての依存関係を再ダウンロード
mvn dependency:purge-local-repository

5. 更新間隔を変更

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
<!-- pom.xml -->
<repositories>
    <repository>
        <id>central</id>
        <url>https://repo.maven.apache.org/maven2</url>
        <releases>
            <updatePolicy>always</updatePolicy> <!-- 毎回チェック -->
        </releases>
        <snapshots>
            <updatePolicy>always</updatePolicy>
        </snapshots>
    </repository>
</repositories>

デバッグ方法

1
2
3
4
5
6
7
8
# キャッシュ状態を確認
ls -la ~/.m2/repository/com/example/my-library/1.0.0/

# .lastUpdated ファイルの内容を確認
cat ~/.m2/repository/com/example/my-library/1.0.0/my-library-1.0.0.jar.lastUpdated

# 詳細なデバッグ出力
mvn clean install -X -U

関連エラー

関連エラー

Java の他のエラー

最終更新: 2026-02-12