gradle - 如何为 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
添加更多文本,因此帖子主要不是代码
解决方案
您应用的 Lombok 插件版本可能与您的 Gradle 版本不兼容。该项目网站指出,与 Gradle 兼容的最新版本4.10.2
是2.x
分支,特别是2.9.5
. 因此,您要么使用它,要么升级到更新的 Gradle 版本。
兼容性矩阵
插件版本 | 摇篮版本 | Java版 |
---|---|---|
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 Boot Gradle 插件的兼容性。
Spring Boot 的 Gradle 插件需要 Gradle 5.x 或 6.x(也支持 4.10,但此支持已弃用,将在未来版本中删除)。
(来自:Spring Boot Gradle 插件参考指南)
更新
在仔细查看您的内容后build.gradle
,您已经在dependencies
块中定义了 Lombok 处理:
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
您可以使用此插件或 Lombok 插件。两者不需要同时应用。
推荐阅读
- python - 如何在 Python 中将字符串“3x a;2x b”转换为字符串“aaab b”?
- django - 如何锚定 django 页面的一部分?
- r - 通过添加列/向量来更新 R 中的文件
- c# - 使用自定义属性从 C# 中的引用项目初始化主类中的自定义属性
- python - 更优雅的装箱方式
- python - 在多索引数据框中添加缺失日期索引
- java - 是否可以使用 java -cp 运行不在包中的类
- graphite - Graphite 未显示最近的数据
- ruby - Chef - 读出节点属性并将其存储在同一厨师客户端运行中的另一个节点属性中失败
- java - 如何自定义材质组件的日期范围选择器的颜色和其他内容?