首页 > 解决方案 > 不能在类上使用 lombok @NoArgsConstructor

问题描述

我将 Jackson 用作 Json 解析器,但出现错误:

No suitable constructor found for type ~ can not instantiate from JSON object

所以我尝试添加@NoArgsConstructor,但现在我得到了这个:

constructor AccountItem in class AccountItem cannot be applied to given types

这是我的课:

@Getter
@Builder
public class AccountItem {

/**
 * Accounti dentifier
 */
private Long accountId;

/**
 * Account name
 */
private String accountName;

/**
 * Account priority
 */
private int accountPriority;
}

可能是什么原因?

标签: javajacksonlombok

解决方案


向您的班级添加@AllArgsConstructor@NoArgsConstructor注释


推荐阅读