ソフラボの技術ブログ

仕事で使ったプログラミング、サーバー周りで役に立つこと、Webサービス開発に必要な技術情報、モバイル情報を書いてます。わかりやすく見やすくをモットーにしています。

Gradle 4.x で「Could not resolve all artifacts for configuration」のエラーが出たときの対処方法

個人的にGradleはよく分かってないので突っ込まれると回答できません。ご了承下さい。

※ 一概に「Could not resolve all artifacts for configuration」のエラーが出たら、ここの対処をすれば良いと言うわけではない点にご注意下さい。

環境

Mac
Spring Boot 1.3.6
Gradle 4.9 (Homebrew)

エラー内容

gradle eclipse等を実行すると以下のエラーが発生する。

* What went wrong:
A problem occurred configuring root project 'Test'.
> Could not resolve all artifacts for configuration ':classpath'.
   > Could not find org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}.
     Required by:
         project :

build.gradle(一部抜粋)

buildscript {
    ext {
        springBootVersion = '1.3.6.RELEASE'
    }
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}'
        // Gradle4対応
        classpath 'io.spring.gradle:dependency-management-plugin:0.6.0.RELEASE'
    }
}

対処方法

build.gradle(一部抜粋)

buildscript {
    ext {
        springBootVersion = '1.3.6.RELEASE'
    }
    repositories {
        mavenCentral()
    }
    dependencies {
        // 変数ではなく固定値にする
        classpath 'org.springframework.boot:spring-boot-gradle-plugin:1.3.6.RELEASE'
        // Gradle4対応
        classpath 'io.spring.gradle:dependency-management-plugin:0.6.0.RELEASE'
    }
}

Gradle徹底入門 次世代ビルドツールによる自動化基盤の構築

Gradle徹底入門 次世代ビルドツールによる自動化基盤の構築