有谁知道什么已经取代了AmazonDynamoDBClient?在文档中找不到任何内容
包 - com.amazonaws.services.dynamodbv2
AmazonDynamoDBClient amazonDynamoDBClient = new AmazonDynamoDBClient();
Run Code Online (Sandbox Code Playgroud)
not*_*est 14
根据API文档,构建器类(例如AmazonDynamoDBClientBuilder)应该用于创建实例.
使用构建器类的示例代码: -
我已经为DynamoDB本地创建了客户端.
DynamoDB dynamoDB = new DynamoDB(AmazonDynamoDBClientBuilder.standard().withEndpointConfiguration(new EndpointConfiguration("http://localhost:8000", "us-east-1")).build());
Table table = dynamoDB.getTable("Movies");
Run Code Online (Sandbox Code Playgroud)
使用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());
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7284 次 |
| 最近记录: |