DynamoDBMapper Maps支持(java)

时间:2016-09-13 11:47:13

标签: amazon-dynamodb

我正在尝试使用com.amazonaws.services.dynamodb.datamodeling.DynamoDBMapper.save()编写地图并收到此错误:

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

DynamoDBMapper不支持地图吗?

1 个答案:

答案 0 :(得分: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)