已弃用的 AmazonDynamoDBClient 的替代方案是什么? [英] What is the alternative for AmazonDynamoDBClient that got deprecated?
本文介绍了已弃用的 AmazonDynamoDBClient 的替代方案是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有谁知道什么取代了 AmazonDynamoDBClient?在文档中找不到任何内容
Does anyone know what has replaced AmazonDynamoDBClient? Couldn't find anything in the documentation
包 - com.amazonaws.services.dynamodbv2
Package - com.amazonaws.services.dynamodbv2
AmazonDynamoDBClient amazonDynamoDBClient = new AmazonDynamoDBClient();
推荐答案
根据 API doc,应使用构建器类(例如 AmazonDynamoDBClientBuilder
)来创建实例.
As per the API doc, the builder class (e.g. AmazonDynamoDBClientBuilder
) should be used to create the instance.
使用构建器类的示例代码:-
我已经为本地 DynamoDB 创建了客户端.
I have create the client for DynamoDB local.
DynamoDB dynamoDB = new DynamoDB(AmazonDynamoDBClientBuilder.standard().withEndpointConfiguration(new EndpointConfiguration("http://localhost:8000", "us-east-1")).build());
Table table = dynamoDB.getTable("Movies");
使用 DynamoDB 表类进行扫描:-
private static void findProductsForPriceLessThanZero() {
Table table = dynamoDB.getTable(tableName);
Map<String, Object> expressionAttributeValues = new HashMap<String, Object>();
expressionAttributeValues.put(":pr", 100);
ItemCollection<ScanOutcome> items = table.scan(
"Price < :pr", //FilterExpression
"Id, Title, ProductCategory, Price", //ProjectionExpression
null, //ExpressionAttributeNames - not used in this example
expressionAttributeValues);
System.out.println("Scan of " + tableName + " for items with a price less than 100.");
Iterator<Item> iterator = items.iterator();
while (iterator.hasNext()) {
System.out.println(iterator.next().toJSONPretty());
}
}
这篇关于已弃用的 AmazonDynamoDBClient 的替代方案是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文