Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/kubernetes/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring 如何忽略Jackson添加的默认属性?_Spring_Jackson_Rabbitmq - Fatal编程技术网

Spring 如何忽略Jackson添加的默认属性?

Spring 如何忽略Jackson添加的默认属性?,spring,jackson,rabbitmq,Spring,Jackson,Rabbitmq,我使用jackson制作JSON对象。我发现jackson会自动添加默认属性。我真的不需要这个字段,我如何删除它 这是我简化的代码 @JsonIgnoreProperties(value = {"@id"}) @JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class, scope = CustomMessage.class) public class SystemMessage {

我使用jackson制作JSON对象。我发现jackson会自动添加默认属性。我真的不需要这个字段,我如何删除它

这是我简化的代码

@JsonIgnoreProperties(value = {"@id"})
@JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class, scope = CustomMessage.class)
public class SystemMessage {
     private String body;
     }
 }
即使我添加了JsonIgnoreProperties注释,它也不会被删除。我想是因为“@id”是默认属性

{@id:1,“body”:“hello”}


这是我从rabbitMQ获得的消息。

添加了
@Id
,因为
@JsonIdentityInfo
注释-请参见您可以看到的地方,这是
属性
字段的默认值

此注释用于父子关系,尤其是当对象之间存在循环依赖关系时。因此,如果这对您来说不是真的,您可以忽略此注释