[英]Spring Boot plugin requires Gradle 4.10 or later. The current version is Gradle 4.1
我有一個 Spring Gradle 項目。 我正在嘗試使用gradle build
命令進行gradle build
。 但得到以下錯誤:
* Where:
Build file 'F:\MyProjectName\build.gradle' line: 2
* What went wrong:
An exception occurred applying plugin request [id: 'org.springframework.boot', version: '2.2.2.RELEASE']
> Failed to apply plugin [id 'org.springframework.boot']
> Spring Boot plugin requires Gradle 4.10 or later. The current version is Gradle 4.1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
BUILD FAILED in 1s
但我已經在使用我正在使用gradle-5.6.4 。 並嘗試了最新的gradle-6.0.1-bin但得到同樣的錯誤。
gradle-wrapper.properties
#Wed Dec 04 12:51:57 IST 2019
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
構建.gradle
plugins {
id 'org.springframework.boot' version '2.2.1.RELEASE'
id 'io.spring.dependency-management' version '1.0.8.RELEASE'
id 'java'
}
group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-mongodb-reactive'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'io.jsonwebtoken:jjwt:0.9.1'
implementation 'org.springframework.security:spring-security-jwt:1.0.7.RELEASE'
implementation 'org.springframework.security.oauth:spring-security-oauth2:2.4.0.RELEASE'
implementation 'de.mkammerer:argon2-jvm:2.6'
compileOnly 'org.projectlombok:lombok:1.18.10'
annotationProcessor 'org.projectlombok:lombok:1.18.10'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
testImplementation 'io.projectreactor:reactor-test'
testImplementation 'org.springframework.security:spring-security-test'
}
jar {
enabled true
}
test {
useJUnitPlatform()
}
如何解決這個問題? 提前致謝。
如果您使用命令gradle build
,那么您沒有使用包裝器,因此不會使用包裝器屬性中配置的 gradle 版本。 您正在使用機器上安裝的全局 gradle 版本。
要使用 gradle 包裝器,請使用
./gradlew build
或者,在 Windows 上
.\gradlew.bat build
在您的項目根文件夾中。
文檔。
gradle-wrapper.properties
distributionUrl
的值類似於distributionUrl=https\\://services.gradle.org/distributions/gradle-5.6.2-bin.zip
請注意,這將升級本地范圍的 gradle 版本。 (與系統范圍的 gradle 安裝相反)您必須使用 gradlew(rapper) 來調用。
例如(基於Linux)
./gradlew 構建
我猜它在 Windows 上會類似
.\gradlew.bat build
你不能使用
gradle build
因為這將調用機器范圍的版本(可能是舊版本)
完整的本地范圍輸出如下:
./gradlew build
Welcome to Gradle 5.6.2!
Here are the highlights of this release:
- Incremental Groovy compilation
- Groovy compile avoidance
- Test fixtures for Java projects
- Manage plugin versions via settings script
就我而言,原因是舊的settings.gradle
駐留在項目完全不相關的父(!)目錄中。
在我的情況下,同一工作區“.settings/org.eclipse.buildship.core.prefs”文件中的其他一些項目具有以下屬性
gradle.user.home=C\:/Gradle/gradle-6.7/bin(old version)
替換為以下內容:
gradle.user.home=C\:/Gradle/gradle-7.3.2/bin(new version)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.