发送对象到后端时UnrecognizedPropertyException出现了。我检查了对象的前端和后端,它看起来是一样的。
然而,当我在前端控制台检查此对象时,我可以看到它具有在项目中没有定义的附加属性(我试图在IntelliJ ctrl + shift + f上搜索它)。
这个属性一段时间以前就在对象中了,所以它可能以某种方式被兑现了?我已经尝试在IntelliJ/npm clean-install等中清除缓存/无效缓存。
如何检查该属性在对象中的位置?
@JsonIgnoreProperties在我的情况下不是一个选项…
前端对象(Angular 8 + Typescript 2.6.2):export class ItemEto extends AbstractEto {
item1: number;
item2: number;
}
export class AbstractEto {
id: number;
modificationCounter: number;
}
后端对象(Java 8):
public class ItemEto extends AbstractEto {
private long item1;
private long item2;
}
public class AbstractEto {
private long id;
private long modificationCounter;
}
控制台上的对象(JSON):
{
"ItemEto": {
"item1": 1,
"item2": 2,
"otherUnknownProperty": {
"item3": null;
},
}
}
要么你有"未知";属性abstract或者你忘了映射ItemEto