[英]Failed to instantiate java.util.List using constructor NO_CONSTRUCTOR with arguments ]
i am getting 我正进入(状态
Failed to instantiate java.util.List using constructor NO_CONSTRUCTOR with arguments ] with root cause
org.springframework.beans.BeanInstantiationException: Failed to instantiate [java.util.List]: Specified class is an interface
this exception while updating the mongodb nested document. 更新mongodb嵌套文档时出现此异常。
the problem is the same as it is dicscuseed it this link 问题是这个链接的dicscuseed相同
http://forum.spring.io/forum/spring-projects/data/nosql/724397-mapping-exception-with-mongodb-aggregation-framework http://forum.spring.io/forum/spring-projects/data/nosql/724397-mapping-exception-with-mongodb-aggregation-framework
but still no clue how to solve it. 但仍然不知道如何解决它。 anyone gone thorugh this??
有谁去过这个?
I just had the same problem and solved it thanks to: Mongo db java unwind operation in aggregate query throwing exception 我只是遇到了同样的问题并解决了它,这要归功于: Mongo db java unwind操作在聚合查询中抛出异常
When in the aggregation the unwind happened, the results are flattened so in my case I had a class like: 在聚合中放松发生时,结果变平了,所以在我的情况下,我有一个类如下:
MyClass {
String _id;
List<SomeObject> objectList;
}
The exception occurs because of the flattening, the results on my list object instead of coming up in an array, now are just a single object because of the $unwind. 出现异常是因为展平,我的列表对象上的结果而不是数组中的结果,现在因为$ unwind而只是一个对象。
What I did to fix this was to create the same class without the list: 我为解决这个问题所做的是创建没有列表的同一个类:
MyClassAggregationResult {
String _id;
SomeObject objectList;
}
This way the results are mapped correctly. 这样就可以正确映射结果。
Hope this works for you as well. 希望这也适合你。
change to as below it should work 改为如下,它应该工作
String _id; String _id;
SomeObject objectList; SomeObject objectList;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.