如何在Mongo DB中存储哈希图

时间:2019-08-16 08:57:55

标签: hashmap spring-data-jpa spring-mongodb

我对Spring JPA和Mongo还是很陌生,我希望将HashMap添加到要持久保存的对象中,如下所示:

public class Fruit {

private Map<String, String> attributes;

}

如果我使用列表,这会起作用,但是使用Map我会得到:

ERROR] 2019-08-16 04:45:18.710 [http-nio-9000-exec-6] [dispatcherServlet] - Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type [java.util.ArrayList<?>] to type [java.util.Map<?, ?>] for value '[59a19673e3cfe23bbd8caed2, 59a19673e3cfe23bbd8caec8, 59a19673e3cfe23bbd8caec7]'; nested exception is org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.lang.String] to type [java.util.Map<?, ?>]] with root cause
org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.lang.String] to type [java.util.Map<?, ?>]
    at org.springframework.core.convert.support.GenericConversionService.handleConverterNotFound(GenericConversionService.java:324) ~[spring-core-4.3.10.RELEASE.jar:4.3.10.RELEASE]

0 个答案:

没有答案