lombok idea gradle @AllArgsConstructor(staticName = "of")找不到符号
环境配置:
- idea:
IntelliJ IDEA 2020.1.1 (Community Edition)
Build #IC-201.7223.91, built on April 30, 2020
- jdk:
java version "1.8.0_91"
Java(TM) SE Runtime Environment (build 1.8.0_91-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)
- gradle:
Gradle 6.6.1
Build time: 2020-08-25 16:29:12 UTC
Revision: f2d1fb54a951d8b11d25748e4711bec8d128d7e3
Kotlin: 1.3.72
Groovy: 2.5.12
Ant: Apache Ant(TM) version 1.10.8 compiled on May 10 2020
JVM: 1.8.0_91 (Oracle Corporation 25.91-b14)
OS: Mac OS X 10.15.5 x86_64
- lombok IDEA plugin:
0.34-2021.1
Lombok + Gradle @AllArgsConstructor(staticName = "of")找不到符号
问题:使用Gradle+lombok+idea+lombok插件,@Data注解@Getter注解能正常工作,@AllArgsConstructor(staticName = "of")注解无法生成静态构造函数,之前Gradle 3.+的工程能正常运行。配置如下:
plugins {
id 'java'
id 'idea'
id 'application'
}
mainClassName = 'com.zds.LombokSimple'
group 'org.zds'
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
compileOnly 'org.projectlombok:lombok:1.18.10'
}
public class LombokSimple {
public static void main(String[] args) {
Teacher t = Teacher.of("ssss","dd"); //IEDA 不报错
System.out.println(t.getUsername());
}
}
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NonNull;
@Data
@AllArgsConstructor(staticName = "of")
public class Teacher {
@NonNull
private String username;
@NonNull
private String password;
}
查阅参考文档,修改gradle配置,问题解决:
dependencies {
compile 'cn.hutool:hutool-all:5.5.7'
compile group: 'org.freemarker', name: 'freemarker', version: '2.3.29'
compile 'org.slf4j:slf4j-api:1.7.29'
testCompile group: 'junit', name: 'junit', version: '4.12'
compileOnly 'org.projectlombok:lombok:1.18.10'
annotationProcessor 'org.projectlombok:lombok:1.18.10'
}