49

我有以下课程:

@Builder @NoArgsConstructor
public class ConsultationPointOfContact {
    private String fullName;
    private String phoneNumber;
    private String userLogin;   
}

@Builder注释存在时,它会导致@NoArgsConstructor.

我收到错误消息:

Error:(11, 1) java: constructor ConsultationPointOfContact in class models.ConsultationPointOfContact cannot be applied to given types;
  required: no arguments
  found: java.lang.String,java.lang.String,java.lang.String
  reason: actual and formal argument lists differ in length
4

3 回答 3

111

也添加@AllArgsConstructor,这应该可以解决问题

于 2018-03-14T16:12:45.857 回答
7

对我来说是这样的: - 在 IntellIJ 上升级或安装 Lombok 插件并为您的模块启用注释处理复选框

在此处输入图像描述

于 2018-11-30T23:16:10.880 回答
0

Met the same issue with lombok and gradle. The same code works with maven, but throws error when using the gradle way.

So the issue turns out to be with lombok and gradle, so I searched the keywords lombok gradle, and find an article: https://projectlombok.org/setup/gradle.

By referencing the article's tip and added the following to build.gradle, then it works like a charm!

...
dependencies {
...
    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'
...
}
...
于 2021-11-26T07:06:56.893 回答