Java 如何将类getMethod与lombok@Data一起使用

Java 如何将类getMethod与lombok@Data一起使用,java,spring,spring-boot,lombok,Java,Spring,Spring Boot,Lombok,我试图用lombok@Data调用类getMethod()方法来调用模型的getter,但没有得到任何方法异常。以下是我的课程: 型号类别: @Data public class Claim { private String customerName; } Claim.class.get("getCustomerName", String.class) Method threw 'java.lang.NoSuchMethodException' exception

我试图用lombok@Data调用类getMethod()方法来调用模型的getter,但没有得到任何方法异常。以下是我的课程:

型号类别:

@Data
public class Claim {
    private String customerName;
}
Claim.class.get("getCustomerName", String.class)
Method threw 'java.lang.NoSuchMethodException' exception.
用法:

@Data
public class Claim {
    private String customerName;
}
Claim.class.get("getCustomerName", String.class)
Method threw 'java.lang.NoSuchMethodException' exception.
例外情况:

@Data
public class Claim {
    private String customerName;
}
Claim.class.get("getCustomerName", String.class)
Method threw 'java.lang.NoSuchMethodException' exception.

您可以使用以下代码:

new PropertyDescriptor("customerName", claim.getClass()).getReadMethod().invoke(claim)
为了更好的解释