ソフラボの技術ブログ

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

Spring Boot 1.3.x で Gradle 4.x に更新してビルドするとエラーが出る場合の対処法

Gradleのバーションを久々に更新したら、一部のプロジェクトでエラーが出てました。
その時の対処を紹介します。

環境

Mac
Eclipse 4.5
Gradle 4.9(Homebrew)
Spring Boot 1.3.6

エラー内容

gradle eclipseを実行するとbuild.gradleの15行目でエラーが発生と表示されます。

$ gradle eclipse
FAILURE: Build failed with an exception.

* Where:
Build file '/Users/Applications/eclipse/workspace/Test/build.gradle' line: 15

* What went wrong:
A problem occurred evaluating root project 'Test'.
> Failed to apply plugin [class 'io.spring.gradle.dependencymanagement.DependencyManagementPlugin']
   > Could not create task of type 'DependencyManagementReportTask'.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 0s

build.gradle

問題の15行目は、apply 'spring-boot'の宣言です。

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'
	}
}

apply plugin: 'java'
apply plugin: 'eclipse-wtp'
apply plugin: 'spring-boot'  // line: 15

以下略

対処法

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

apply plugin: 'java'
apply plugin: 'eclipse-wtp'
apply plugin: 'spring-boot' 
// 追加
apply plugin: 'io.spring.dependency-management'