Gradle无法建立Lombok注释班

发布于 2025-01-19 23:15:18 字数 2048 浏览 1 评论 0原文

我已将我的项目从 Maven 更改为 gradle。 我的此命令出现错误

./gradlew build --scan

但对于其中包含 lombok 的项目,

。网上的方法我都试过了,没用。 build.gradle 文件采用 kotlin 语言

构建错误输出

这是 build.gradle.kts

/*
 * This file was generated by the Gradle 'init' task.
 */

plugins {
    java
    `maven-publish`
}

repositories {
    mavenLocal()
    maven {
        url = uri("https://repo.maven.apache.org/maven2/")
    }
}

dependencies {
    implementation("org.springframework.boot:spring-boot-starter-data-jpa:2.3.9.RELEASE")
    implementation("org.springframework.boot:spring-boot-starter-validation:2.3.9.RELEASE")
    implementation("org.springframework.boot:spring-boot-starter-actuator:2.3.9.RELEASE")
    implementation("org.springframework.boot:spring-boot-starter-web:2.3.9.RELEASE")
    implementation("org.springframework.cloud:spring-cloud-starter-config:2.2.0.RELEASE")
    implementation("org.springframework.cloud:spring-cloud-starter-sleuth:2.2.0.RELEASE")
    implementation("org.springframework.cloud:spring-cloud-sleuth-zipkin:2.2.0.RELEASE")
    implementation("org.springframework.cloud:spring-cloud-starter-openfeign:2.2.0.RELEASE")
    implementation("org.springframework.cloud:spring-cloud-starter-netflix-eureka-client:2.2.0.RELEASE")
    implementation("io.springfox:springfox-swagger2:2.9.2")
    implementation("io.springfox:springfox-swagger-ui:2.9.2")
    implementation("org.projectlombok:lombok:1.18.18")
    runtimeOnly("mysql:mysql-connector-java:8.0.23")
    testImplementation("org.springframework.boot:spring-boot-starter-test:2.3.9.RELEASE")
}

group = "com.bank"
version = "0.0.1-SNAPSHOT"
description = "transaction"
java.sourceCompatibility = JavaVersion.VERSION_1_8

publishing {
    publications.create<MavenPublication>("maven") {
        from(components["java"])
    }
}

tasks.withType<JavaCompile>() {
    options.encoding = "UTF-8"
}

I had changed my project from maven to gradle. but I had error with this command

./gradlew build --scan

for project that has lombok in it.

I've tried all method from online an it is useless. The build.gradle file is in kotlin language

Build Error Output

Here is the build.gradle.kts

/*
 * This file was generated by the Gradle 'init' task.
 */

plugins {
    java
    `maven-publish`
}

repositories {
    mavenLocal()
    maven {
        url = uri("https://repo.maven.apache.org/maven2/")
    }
}

dependencies {
    implementation("org.springframework.boot:spring-boot-starter-data-jpa:2.3.9.RELEASE")
    implementation("org.springframework.boot:spring-boot-starter-validation:2.3.9.RELEASE")
    implementation("org.springframework.boot:spring-boot-starter-actuator:2.3.9.RELEASE")
    implementation("org.springframework.boot:spring-boot-starter-web:2.3.9.RELEASE")
    implementation("org.springframework.cloud:spring-cloud-starter-config:2.2.0.RELEASE")
    implementation("org.springframework.cloud:spring-cloud-starter-sleuth:2.2.0.RELEASE")
    implementation("org.springframework.cloud:spring-cloud-sleuth-zipkin:2.2.0.RELEASE")
    implementation("org.springframework.cloud:spring-cloud-starter-openfeign:2.2.0.RELEASE")
    implementation("org.springframework.cloud:spring-cloud-starter-netflix-eureka-client:2.2.0.RELEASE")
    implementation("io.springfox:springfox-swagger2:2.9.2")
    implementation("io.springfox:springfox-swagger-ui:2.9.2")
    implementation("org.projectlombok:lombok:1.18.18")
    runtimeOnly("mysql:mysql-connector-java:8.0.23")
    testImplementation("org.springframework.boot:spring-boot-starter-test:2.3.9.RELEASE")
}

group = "com.bank"
version = "0.0.1-SNAPSHOT"
description = "transaction"
java.sourceCompatibility = JavaVersion.VERSION_1_8

publishing {
    publications.create<MavenPublication>("maven") {
        from(components["java"])
    }
}

tasks.withType<JavaCompile>() {
    options.encoding = "UTF-8"
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

久光 2025-01-26 23:15:18

在我看来。你必须将插件应用到你的构建脚本中,正如 lombok 文档 中所说的

那样:

plugins {
  ...
  id "io.freefair.lombok" version "6.4.2"
}

或者你必须提供注释处理器依赖,但我认为该插件更适合。

It seems to me. that you have to apply a plugin to your build script, as it's said in the lombok docs

Something like this:

plugins {
  ...
  id "io.freefair.lombok" version "6.4.2"
}

Or you have to provide annotation processor dependency, but I think that the plugin suits better.

鲜血染红嫁衣 2025-01-26 23:15:18

所以我使用了最新版本而不是 lombok 1.18.18

    compileOnly("org.projectlombok:lombok:1.18.22")
    annotationProcessor("org.projectlombok:lombok:1.18.22")
    testCompileOnly("org.projectlombok:lombok:1.18.22")
    testAnnotationProcessor("org.projectlombok:lombok:1.18.22")

So I've used the latest version instead of lombok 1.18.18

    compileOnly("org.projectlombok:lombok:1.18.22")
    annotationProcessor("org.projectlombok:lombok:1.18.22")
    testCompileOnly("org.projectlombok:lombok:1.18.22")
    testAnnotationProcessor("org.projectlombok:lombok:1.18.22")
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文