在Lombok的Sping Boot 应用程序中,我使用pojo类AccountDTO
@Data
@Builder
@Accessors(fluent = true)
public class AccountDTO implements Serializable {
private String identification;
}
我的项目编译得很好。但是,它在执行过程中抛出了异常
定义无效异常:未找到类AccountDTO的序列化程序,也未找到用于创建BeanSerializer的属性
如果我删除了注解@Accessors(fluent = true)
,那么它将工作正常,没有任何问题。
如何使Lombok
@Accessors(fluent = true)
和Jackson
一起工作?
1条答案
按热度按时间wkftcu5l1#
我最近遇到同样的问题时偶然发现了这个问题,对我来说,解决方案是在Lombok生成的getter上添加显式的
@JsonProperty
注解:@Getter(onMethod = @__(@JsonProperty))
.在您的示例中,类将如下所示: