为什么在我向 POJO 添加新字段后 JSON 没有更改

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

我已将新字段添加到 POJO,希望在我的 Spring 启动应用程序中找到它们作为响应。这是一个带有 Lombok 注释的简单 POJO:

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

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

在我的服务方法中,我创建了对象,然后使用 setter 添加了额外的字段 errorCode:

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

但我仍然收到一个 JSON 和一个字段:

{
    resultCode: "0"
}

如何强制包含新字段?

更新: AsyncResponse 看起来像这样

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

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

网关模块中 application.yml 中设置了一个筛选器,它没有在 fieldsToRetain 参数中提及字段。