解决:Elasticsearch failed to map source

解决:Elasticsearch failed to map source

报错信息

[INFO] Results:
[INFO] 
[ERROR] Errors: 
[ERROR]   CarDoaTest.testQueryByAggs:57 » Elasticsearch failed to map source [ {"color":...
[INFO] 
[ERROR] Tests run: 11, Failures: 0, Errors: 1, Skipped: 0

截图:
在这里插入图片描述

分析

可以看到,在使用泛型的地方出错了

在类Car中,只有有参构造,并没有无参构造,但是jackson的反序列化需要使用无参构造,因此才会报错

解决办法

添加无参构造函数即可

在这里插入图片描述

效果

在这里插入图片描述

测试成功!

猜你喜欢

转载自blog.csdn.net/weixin_44829930/article/details/108880833