0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Mavenでpom.xmlの依存関係がうまくいかないときの対処法

Posted at

Mavenでビルドや依存関係の解決時に、以下のような問題が起きることがあります。

依存ライブラリが取得できない

プラグインのダウンロードが失敗している

ビルドが途中で止まる

原因
Mavenは依存ライブラリやプラグインをローカルリポジトリ(~/.m2/repository)にキャッシュする。
しかし、一度取得に失敗したものはキャッシュに失敗結果が残り、次回のビルドで再取得されないことがある。

対処法:キャッシュの強制更新
以下のコマンドでキャッシュを無視して、依存関係やプラグインをリモートリポジトリから強制的に再取得。

bash
コピーする
編集する

mvn clean install -U

clean :ビルド成果物の削除

install :ビルドしてローカルリポジトリにインストール

-U :依存関係の更新を強制(Update snapshots/releases)

まとめ
依存関係エラーが出たら、まずはmvn clean install -Uを試す。

それでも直らない場合は、~/.m2/repositoryの該当ライブラリを手動削除して再度ビルドすることも効果的。

プロキシ設定などネットワーク環境も合わせて確認。

Mavenでのトラブルシューティングの基本なので、覚えておくと便利!

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?