解决: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的反序列化需要使用无参构造,因此才会报错
解决办法
添加无参构造函数即可
效果
测试成功!