即使我似乎已安装正确的版本,也收到Gradle版本错误

时间:2020-06-28 16:00:56

标签: gradle gradlew

运行Gradle构建时出现此错误:

$ ./gradlew clean build

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/paulcarron/Documents/Documents/Books/Learning Spring Boot 2/learning-spring-boot-2/build.gradle' line: 2

* What went wrong:
An exception occurred applying plugin request [id: 'org.springframework.boot', version: '2.3.1.RELEASE']
> Failed to apply plugin [id 'org.springframework.boot']
   > Spring Boot plugin requires Gradle 5 (5.6.x only) or Gradle 6 (6.3 or later). The current version is Gradle 6.0.1

* 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 759ms

我已经安装了Gradne 6.5:

$ gradle -v

------------------------------------------------------------
Gradle 6.5
------------------------------------------------------------

Build time:   2020-06-02 20:46:21 UTC
Revision:     a27f41e4ae5e8a41ab9b19f8dd6d86d7b384dad4

Kotlin:       1.3.72
Groovy:       2.5.11
Ant:          Apache Ant(TM) version 1.10.7 compiled on September 1 2019
JVM:          1.8.0_121 (Oracle Corporation 25.121-b13)
OS:           Mac OS X 10.15.5 x86_64

这可能是什么问题?

1 个答案:

答案 0 :(得分:2)

只是在评论中微调正确答案。

程序gradle(如果有)将调用系统上安装的Gradle。可能是从您的PATH变量中找到的。

gradlew脚本(注意'w')是包装脚本,通常添加到Git存储库中。它调用Gradle的声明版本,并在必要时自动自动下载。它使用自己的安装文件夹(默认为~/.gradle/wrapper),版本在[repo]/gradle/wrapper/gradle-wrapper.properties中声明。

虽然您可以手动更改版本,但最好运行./gradle wrapper --gradle-version 6.5 --distribution-type all,因为这也会在需要时更新包装器脚本本身。