Spring mvc Spring MVC映射Guava多重映射
我的控制器无法映射来自前端的Google GuavaSpring mvc Spring MVC映射Guava多重映射,spring-mvc,mapping,guava,multimap,Spring Mvc,Mapping,Guava,Multimap,我的控制器无法映射来自前端的Google GuavaMultimap。我从Javascript发送此对象: {1:[true,false], 2:[false,true], ...}. 如果我使用标准 java.util.Map<Long, List<Boolean>> 我的例外是: 是吗?默认情况下,Jackson(以及Spring)不支持序列化或反序列化到Guava数据类型 Guava模块可能适用于您,也可能不适用于您,这取决于您想要的Multimap的实现—
Multimap
。我从Javascript发送此对象:
{1:[true,false], 2:[false,true], ...}.
如果我使用标准
java.util.Map<Long, List<Boolean>>
我的例外是:
是吗?默认情况下,Jackson(以及Spring)不支持序列化或反序列化到Guava数据类型
Guava模块可能适用于您,也可能不适用于您,这取决于您想要的Multimap
的实现——并不是所有的数据类型都实现了。是吗?默认情况下,Jackson(以及Spring)不支持序列化或反序列化到Guava数据类型
Guava模块可能适用于您,也可能不适用于您,这取决于您想要的
Multimap
的实现方式——并不是所有的数据类型都实现了。请更具体一些:向我们显示您的代码(控制器、转换器)和异常。请更具体一些:向我们显示您的代码(控制器、转换器)和异常。啊,我想这就是原因。我的pom中没有该模块。我原以为它会开箱即用:-)谢谢。啊,我想这就是原因。我的pom中没有该模块。我原以为这是开箱即用的:-)谢谢。
@RequestMapping(path = "/myurl", method = RequestMethod.POST, produces = CotrollerKonstanten.JSON_UTF8)
public long myMethod(@RequestBody MappingDto mappingDto) {
//...
}
org.springframework.http.converter.HttpMessageNotReadableException: Could not read document:
Can not construct instance of com.google.common.collect.Multimap, problem:
abstract types either need to be mapped to concrete types, have custom deserializer, or be instantiated with additional type information
at [Source: java.io.PushbackInputStream@4b9c2db; line: 1, column: 13] (through reference chain: ...myClass);
nested exception is com.fasterxml.jackson.databind.JsonMappingException:
Can not construct instance of com.google.common.collect.Multimap, problem: abstract types either need to be mapped to concrete types, have custom deserializer, or be instantiated with additional type information