如何为 io.freefair.lombok 设置插件
How to set plugin for io.freefair.lombok
我正在尝试使用 io.freefair.lombok 插件,但 Gradle 4.10.2 出现错误。怎么设置?
plugins {
id 'org.springframework.boot' version '2.2.5.RELEASE'
id 'io.spring.dependency-management' version '1.0.9.RELEASE'
id "io.freefair.lombok" version "4.0.0" // error on this line
id 'java'
}
group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
repositories {
mavenCentral()
mavenLocal()
}
dependencyManagement {
imports {
mavenBom 'org.springframework.cloud:spring-cloud-dependencies:Hoxton.SR3'
}
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'
implementation 'org.springframework.cloud:spring-cloud-starter-openfeign'
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
runtimeClasspath 'org.springframework.boot:spring-boot-devtools'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
这是错误:
Could not run build action using Gradle distribution 'https://services.gradle.org/distributions/gradle-4.10.2-bin.zip'.
Build file 'C:\Users\user\eclipse-workspace\car-proj\build.gradle' line: 4
An exception occurred applying plugin request [id: 'io.freefair.lombok', version: '5.0.0-rc4']
Failed to apply plugin [class 'io.freefair.gradle.plugins.lombok.LombokBasePlugin']
Could not generate a proxy class for class io.freefair.gradle.plugins.lombok.LombokExtension.
org/gradle/api/provider/MapProperty
org.gradle.api.provider.MapProperty
添加更多文本,这样 post 就不是代码了
您应用的 Lombok 插件版本可能与您的 Gradle 版本不兼容。 project website 声明与 Gradle 4.10.2
兼容的最新版本是 2.x
分支,特别是 2.9.5
。因此,要么使用它,要么升级到更新的 Gradle 版本。
兼容性矩阵
Plugin Version
Gradle Version
Java Version
6.3.x
7.3
8 - 17
6.2.x
7.2
8 - 16
6.1.x
7.1
8 - 16
6.x
7.0
8 - 16
5.3.x
6.7
8 - 15
5.1.x
6.4+
8 - 14
5.0.x
6.3
8 - 13
4.x
5.6+
8 - 12
3.8.x
5.5.x
8 - 12
3.3.x - 3.7.x
5.4+
8 - 12
3.2.x
5.3+
8 - 11
3.x
5.1+
8 - 11
2.x
4.x
8 - 11
您可能还想升级 Gradle 以保持与 Spring 引导 Gradle 插件的兼容性。
Spring Boot’s Gradle plugin requires Gradle 5.x or 6.x (4.10 is also supported but this support is deprecated and will be removed in a future release).
(来自:Spring Boot Gradle Plugin Reference Guide)
更新
在更仔细地检查了您的 build.gradle
之后,您已经在 dependencies
块中定义了 Lombok 处理:
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
您可以使用此插件或 Lombok 插件。无需同时申请。
我正在尝试使用 io.freefair.lombok 插件,但 Gradle 4.10.2 出现错误。怎么设置?
plugins {
id 'org.springframework.boot' version '2.2.5.RELEASE'
id 'io.spring.dependency-management' version '1.0.9.RELEASE'
id "io.freefair.lombok" version "4.0.0" // error on this line
id 'java'
}
group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
repositories {
mavenCentral()
mavenLocal()
}
dependencyManagement {
imports {
mavenBom 'org.springframework.cloud:spring-cloud-dependencies:Hoxton.SR3'
}
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'
implementation 'org.springframework.cloud:spring-cloud-starter-openfeign'
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
runtimeClasspath 'org.springframework.boot:spring-boot-devtools'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
这是错误:
Could not run build action using Gradle distribution 'https://services.gradle.org/distributions/gradle-4.10.2-bin.zip'.
Build file 'C:\Users\user\eclipse-workspace\car-proj\build.gradle' line: 4
An exception occurred applying plugin request [id: 'io.freefair.lombok', version: '5.0.0-rc4']
Failed to apply plugin [class 'io.freefair.gradle.plugins.lombok.LombokBasePlugin']
Could not generate a proxy class for class io.freefair.gradle.plugins.lombok.LombokExtension.
org/gradle/api/provider/MapProperty
org.gradle.api.provider.MapProperty
添加更多文本,这样 post 就不是代码了
您应用的 Lombok 插件版本可能与您的 Gradle 版本不兼容。 project website 声明与 Gradle 4.10.2
兼容的最新版本是 2.x
分支,特别是 2.9.5
。因此,要么使用它,要么升级到更新的 Gradle 版本。
兼容性矩阵
Plugin Version | Gradle Version | Java Version |
---|---|---|
6.3.x | 7.3 | 8 - 17 |
6.2.x | 7.2 | 8 - 16 |
6.1.x | 7.1 | 8 - 16 |
6.x | 7.0 | 8 - 16 |
5.3.x | 6.7 | 8 - 15 |
5.1.x | 6.4+ | 8 - 14 |
5.0.x | 6.3 | 8 - 13 |
4.x | 5.6+ | 8 - 12 |
3.8.x | 5.5.x | 8 - 12 |
3.3.x - 3.7.x | 5.4+ | 8 - 12 |
3.2.x | 5.3+ | 8 - 11 |
3.x | 5.1+ | 8 - 11 |
2.x | 4.x | 8 - 11 |
您可能还想升级 Gradle 以保持与 Spring 引导 Gradle 插件的兼容性。
Spring Boot’s Gradle plugin requires Gradle 5.x or 6.x (4.10 is also supported but this support is deprecated and will be removed in a future release).
(来自:Spring Boot Gradle Plugin Reference Guide)
更新
在更仔细地检查了您的 build.gradle
之后,您已经在 dependencies
块中定义了 Lombok 处理:
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
您可以使用此插件或 Lombok 插件。无需同时申请。