运行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
这可能是什么问题?
最佳答案
只是为了细化评论中的正确答案。
程序gradle
(如果有)将调用系统上安装的Gradle。可能是从您的PATH变量中找到的。gradlew
脚本(注意'w')是通常添加到Git存储库中的包装器脚本。它调用Gradle的声明版本,并在必要时自动自动下载。它使用自己的安装文件夹(默认情况下为~/.gradle/wrapper
,版本在[repo]/gradle/wrapper/gradle-wrapper.properties
中声明)。
虽然可以手动更改版本,但最好运行./gradle wrapper --gradle-version 6.5 --distribution-type all
,因为这也会在需要时更新包装器脚本本身。
关于gradle - 即使我似乎安装了正确的版本,也遇到了Gradle版本错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62624974/