简体   繁体   中英

Why did not JSON change after I added new fields to POJO

I have added new fields to POJO expecting to find them in response in my Spring Boot application. It is a simple POJO with Lombok annotations:

@Getter
@Setter
@NoArgsConstructor
public class Responce implements AsyncResponse, Serializable {
    private String resultCode;
    private String errorCode; // added field

public Responce(String resultCode) {
    this.resultCode = resultCode;
    }
}

In my service method I have created object and then used a setter for added extra field errorCode:

Responce response = new Responce("0");
responce.setErrorCode("777");

But I still receive a JSON with one field:

{
    resultCode: "0"
}

How I can force to include new field?

UPD: AsyncResponse looks like this

public interface AsyncResponse {
    String getResultCode();
    void setResultCode(String resultCode);

    String getErrorCode(); // added getter
    void setErrorCode(String errorCode); // added setter
}

在网关模块的 application.yml 中设置了一个过滤器,它没有提到 fieldsToRetain 参数中的字段。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM