2016-07-12 5 views
0

컨트롤러가 Google 프런트 엔드에서 오는 Google Guava Multimap을 매핑 할 수 없습니다. 나는 표준봄 MVC 매핑 Guava Multimap

java.util.Map<Long, List<Boolean>> 

모든 것이 잘 작동 사용하는 경우

{1:[true,false], 2:[false,true], ...}. 

: 내 자바 스크립트에서이 객체를 보낼 수 있습니다. 그러나 구아바가 아닌 Multimap. 일부 사용자 정의 변환기를 사용하도록 Spring을 구성해야합니까, 아니면 무엇이 문제입니까?

컨트롤러는 다음과 같습니다

@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: [email protected]; 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 
+0

자세한 내용을 알려주십시오 : 코드 (컨트롤러, 변환기)와 예외 사항을 알려주십시오. – Xaerxess

답변

2

당신에게 register the Guava module을 했습니까? 기본적으로 Jackson (및 Spring)은 Guava 데이터 유형에 대한 직렬화 또는 비 직렬화를 지원하지 않습니다.

Guaya 모듈은 원하는 데이터 유형이 구현되지 않은 경우 Multimap의 구현에 따라 제대로 작동하지 않을 수도 있습니다.

+0

아, 그 때가 그 이유입니다. 내 숙면에 모듈이 없어. 상자 밖으로 나올 거라 생각했는데 :-) 고마워. –