简体   繁体   English

无法使用带参数的构造函数NO_CONSTRUCTOR实例化java.util.List]

[英]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.

相关问题 “无法使用带有 arguments 的构造函数 NO_CONSTRUCTOR 实例化 java.util.List ”, - “Failed to instantiate java.util.List using constructor NO_CONSTRUCTOR with arguments ”, 无法使用带参数的构造函数 NO_CONSTRUCTOR 实例化 java.util.Set - Failed to instantiate java.util.Set using constructor NO_CONSTRUCTOR with arguments Spring data elasticsearch:throws MappingInstantiationException: Failed to instantiate java.util.Set using constructor NO_CONSTRUCTOR with arguments - Spring data elasticsearch:throws MappingInstantiationException: Failed to instantiate java.util.Set using constructor NO_CONSTRUCTOR with arguments 使用带参数的构造函数NO_CONSTRUCTOR无法实例化org.springframework.security.authentication.UsernamePasswordAuthenticationToken - Failed to instantiate org.springframework.security.authentication.UsernamePasswordAuthenticationToken using constructor NO_CONSTRUCTOR with arguments 如何修复不可变类中的“无法使用带参数的构造函数 NO_CONSTRUCTOR 实例化‘className’” - How to fix " Failed to instantiate 'className' using constructor NO_CONSTRUCTOR with arguments" in immutable class Spring-data-mongo 无法使用构造函数实例化 java.util.List - Spring-data-mongo unable to instantiate java.util.List using Constructor 无法解析构造函数&#39;ArrayList(java.util.List <T> )`在Java中 - Cannot resolve constructor 'ArrayList(java.util.List<T>)` in Java 无法实例化[java.util.List]:指定的类是GET请求中的接口 - Failed to instantiate [java.util.List]: Specified class is an interface in GET request spring boot - 如何在HTTP控制器处理程序中避免“无法实例化[java.util.List]:指定的类是一个接口”? - spring boot - how to avoid “Failed to instantiate [java.util.List]: Specified class is an interface” in HTTP controller handler? 找不到AttributedString(java.util.List <java.lang.String> ) - no suitable constructor found for AttributedString(java.util.List<java.lang.String>)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM