Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/328.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法使用构造函数实例化java.util.List NO_构造函数(带参数)]_Java_Spring_Mongodb - Fatal编程技术网

无法使用构造函数实例化java.util.List NO_构造函数(带参数)]

无法使用构造函数实例化java.util.List NO_构造函数(带参数)],java,spring,mongodb,Java,Spring,Mongodb,我越来越 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 更新mongodb嵌套文档时发

我越来越

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
更新mongodb嵌套文档时发生此异常

这个问题和它在这个链接上的问题是一样的


但仍然不知道如何解决它。有人经历过这个吗?

我也遇到了同样的问题,多亏了:

在聚合中展开时,结果是平坦的,因此在我的例子中,我有一个类,如:

MyClass {
   String _id;
   List<SomeObject> objectList;
}
这样可以正确映射结果


希望这也适用于您。

更改为以下内容,它应该会起作用

字符串_id


SomeObject对象列表

我没有使用mongodb的经验,但是映射程序试图实例化一个
列表
,但它不起作用,因为它是一个接口。一种解决方法是说服映射程序在需要
列表时实例化
ArrayList
。Edit:实际上,您显示的线程中的问题是查询返回了一个对象而不是单个元素列表,从而使映射程序无法识别数组。你的问题也一样吗?@JeremyGrand你能帮我解决一下吗?@JeremyGrand我的问题没有代码有点模糊。考虑添加完整的代码,包括运行时将抛出异常的示例文档
MyClassAggregationResult {
  String _id;
  SomeObject objectList;
}