当我使用 javapoet 时,有什么方法(和任何意义)可以使用 Lombok 吗?
这是示例:
TypeSpec typeSpec = TypeSpec
.classBuilder("MyDtoWithLombok")
.addModifiers(Modifier.PUBLIC)
//.addAnnotation(NoArgsConstructor.class)
//.addAnnotation(AllArgsConstructor.class)
//.addAnnotation(Data.class)
//.addAnnotation(Builder.class)
.addField(...)
.build();
当我尝试添加 Lombok 注释时(例如 -> Data.class"),我收到以下错误:
Exception in thread "main" java.lang.NoClassDefFoundError: lombok/NoArgsConstructor
...
Caused by: java.lang.ClassNotFoundException: lombok.NoArgsConstructor
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 3 more