Spring Boot Gradle无法生成lombok注解类

q3qa4bjr  于 2023-10-16  发布在  Spring
关注(0)|答案(2)|浏览(111)

我把我的项目从maven改为gradle。但是我在这个命令上有错误

./gradlew build --scan

有Lombok岛的项目
我试过网上所有的方法,都没用。build.gradle文件使用Kotlin语言

这里是构建.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"
}
bnlyeluc

bnlyeluc1#

在我看来。你必须在你的构建脚本中应用一个插件,就像lombok docs中所说的那样,
大概是这样的:

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

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

r7xajy2e

r7xajy2e2#

所以我用的是最新版本而不是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")

相关问题