2016-07-12 9 views
0

私のコントローラはフロントエンドから来るGoogle Guava Multimapをマッピングできません。私は標準Spring MVCマッピングGuava Multimap

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

すべてが正常に動作します使用している場合

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

:私は私のJavaScriptからこのオブジェクトを送信します。しかし、グアバではない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

ああ、それが理由だと思います。私はポームの中にモジュールを持っていません。私はそれが箱から働くと思った:-)ありがとう。 –

関連する問題