使用jackson mixin序列化json时忽略空值

使用jackson mixin序列化json时忽略空值,json,jackson,Json,Jackson,将对象序列化为JSON时,我需要忽略空值。自从我 没有访问对象源的权限,我对这两个类都使用Mixin类 ObjectMapper和Jackson2ObjectMapperBuilder在我的springbootplication类中: public void onApplicationEvent(ObjectMapperConfigured event) { ObjectMapper om = event.getObjectMapper(); om.setSerializatio

将对象序列化为JSON时,我需要忽略空值。自从我 没有访问对象源的权限,我对这两个类都使用Mixin类
ObjectMapper
Jackson2ObjectMapperBuilder
在我的
springbootplication
类中:

public void onApplicationEvent(ObjectMapperConfigured event) {
    ObjectMapper om = event.getObjectMapper();
    om.setSerializationInclusion(Include.NON_NULL);
    ....................................................
    om.addMixInAnnotations(target_class_I_dont_have_access_to.class, my_mixin_class.class);
    .........................................


public Jackson2ObjectMapperBuilder objectMapperBuilder() {
   Jackson2ObjectMapperBuilder omb = new Jackson2ObjectMapperBuilder();
   omb.serializationInclusion(Include.NON_NULL);
   ...................................................
   omb.mixIn(target_class_I_dont_have_access_to.class, my_mixin_class.class);
   .......................................................................
这对JSON输出没有影响

我还尝试过用
@JsonInclude(Include.NON_NULL)
注释Mixin类,但这也不起作用

有没有办法让它工作起来?感谢您的帮助

罗马人