The subclass is returned after the Java feign interface is called, and the serialized subclass deserializes only the parent class

The serialization method needs to be modified

When I saved the subclass, I received only the data of the parent class

Feign uses jackson for serialization by default, and needs to be annotated on the parent class

@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS)
adds annotations to the parent class header:

import com.fasterxml.jackson.annotation.JsonTypeInfo;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/*************************************
 *Class Name: BaseObject
 *Description: <基础类>
 *@author: Seminar
 *@create: 2023/7/22
 *@since 1.0.0
 *************************************/
@Data
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS)
public class BaseObject {
    
    

    private String id;
    private String name;
}

reference

Guess you like

Origin blog.csdn.net/qq_40985985/article/details/131892350