gpt4 book ai didi

java - 与 ObjectMapper 一起使用注释 Mixins 时出错

转载 作者:行者123 更新时间:2023-11-30 04:29:50 25 4
gpt4 key购买 nike

我正在尝试使用以下代码为我的 POJO 之一创建一个 mixin:

interface CustomerStatsIgnoreMixIn {
@JsonIgnoreProperties({"ref"});
}

public class CustomerStatsJob extends Job {
private void updateCustomer(Customer customer) {
ObjectMapper mapper = new ObjectMapper();
mapper.getSerializationConfig().addMixInAnnotations(Customer.class,
CustomerStatsIgnoreMixIn.class);
}
}

我在 Eclipse 行中收到以下错误 @JsonIgnoreProperties({"ref"});

Multiple markers at this line - Syntax error, insert "enum Identifier" to complete EnumHeaderName - Syntax error, insert "EnumBody" to complete EnumDeclaration

我确信这很愚蠢,但你知道问题出在哪里吗?

最佳答案

JsonIgnoreProperties 注释是一个类型注释...它应该位于接口(interface)定义行的正上方,而不是接口(interface)主体中。

喜欢:

@JsonIgnoreProperties({"ref"});
interface CustomerSTatesIgnoreMixin {

希望这有帮助。

关于java - 与 ObjectMapper 一起使用注释 Mixins 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14896726/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com