Gitは新しいプロジェクトをクローンし、Gradleをビルドし、次のエラーメッセージを表示します:

ターミナル

$ gradle clean build

FAILURE: Build failed with an exception.

**  Where:
Build file '/Users/mkyong/Documents/workspace/hc2/web/build.gradle' line: 25

**  What went wrong:
A problem occurred evaluating project ':web'.
> Could not find method compileOnly() for arguments[org.springframework.boot:spring-boot-starter-tomcat]on project ':web'.

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

BUILD FAILED

Gradle 2.4を使用する

ターミナル

gradle -version

------------------------------------------------------------

Gradle 2.4
-------------------------------------------------- ----------

構築時間:2015-05-05 08:09:24 UTC
ビルド番号:なし
リビジョン:5c9c3bc20ca1c281ac7972643f1e2d190f2c943c

Groovy:2.3.10
Ant:2014年4月29日にコンパイルされたApache Ant(TM)バージョン1.9.4
JVM:1.8.0__74(Oracle Corporation 25.74-b02)
OS:Mac OS X 10.12.6 x86__64

解決策

スコープ `compileOnly`はhttps://blog.gradle.org/introducing-compile-only-dependencies,Gradle 2.12以降に導入されています。修正するには、Gradleを最新のバージョンにアップグレードするだけです.Gradle 4.1は8月にリリースされました07,2017。

参考文献

ブログ – コンパイルのみの依存関係の紹介]。

Gradle release