2016-09-13 90 views
1

我想寫使用com.amazonaws.services.dynamodb.datamodeling.DynamoDBMapper.save()地圖和正在此錯誤:DynamoDBMapper地圖支持(JAVA)

Exception in thread "main" 
com.amazonaws.services.dynamodb.datamodeling.DynamoDBMappingException: 
Unsupported type: interface java.util.Map for public java.util.Map Config.getAttributes() 

是地圖不支持DynamoDBMapper

回答

0

創建HashMapMarshaller

public class HashMapMarshaller extends JsonMarshaller<HashMap<String, String>> 

{ 
    @Override 
    public String marshall(HashMap<String, String> obj) { 
     return super.marshall(obj); 
    } 

    @Override 
    public HashMap<String, String> unmarshall(Class<HashMap<String, String>> clazz, String json) { 
     return super.unmarshall(clazz, json); 
    } 
} 

然後將其分配給你的財產

@DynamoDBMarshalling(marshallerClass=HashMapMarshaller.class)