有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

使用Lombok项目的java不明确方法调用

我有以下代码:

import lombok.Builder;
import lombok.Getter;

@Getter
@Builder
public class NameParserResponse {
    private boolean match;
}


public class Main {

    public static void main(String[] args) {
        NameParserResponse nameParserResponse = NameParserResponse.builder().build();
        nameParserResponse.isMatch();
    }
}

尝试引用isMatch()时,我得到:

Ambiguous method call. Both

isMatch () in Response and
isMatch () in Response match

enter image description here

我还尝试删除@Builder注释,但这没有帮助


共 (2) 个答案

  1. # 1 楼答案

    IntelliJ对代码进行了重构,将Lombok魔法扩展到它在幕后自动生成的更冗长的代码中。当我以前遇到类似这样的奇怪情况时,查看实际生成的代码,而不是仅仅猜测,有助于使问题更清楚。YMMV

    祝你好运

  2. # 2 楼答案

    看起来除了Project Lombok插件之外,我还安装了HriseyIntellij插件。我一定是在寻找Project Lombok插件时意外安装了这个插件

    禁用此插件后,问题不再存在