【问题标题】:Not able to create Multiple Attribute in DynamoDB无法在 DynamoDB 中创建多个属性
【发布时间】:2022-01-16 13:59:08
【问题描述】:

我需要创建一个具有四个属性的 DynamoDB 表。我正在使用以下 Java 程序:

String tableName = "devtest";

Table table = dynamoDB.createTable(tableName,
                    Arrays.asList(new KeySchemaElement("BIC", KeyType.HASH)), // Sort key
                    Arrays.asList(new AttributeDefinition("BIC", ScalarAttributeType.S),
                        new AttributeDefinition("Tenant", ScalarAttributeType.S),
                        new AttributeDefinition("TenantID", ScalarAttributeType.S),
                        new AttributeDefinition("Destination", ScalarAttributeType.S)),
                    new ProvisionedThroughput(10L, 10L));
table.waitForActive();
System.out.println("Success.  Table status: " + table.getDescription().getTableStatus());  
        

我总是收到以下错误:

Unable to create table: 
Unable to unmarshall exception response with the unmarshallers provided (Service: AmazonDynamoDBv2; Status Code: 400; Error Code: ValidationException; Request ID: bc0565ac-9d44-4876-934a-b39fbe8ca3f1)

如何解决这个错误?

【问题讨论】:

  • 听起来您可能没有适当的权限来创建表
  • 我有,我正在使用本地主机 AmazonDynamoDB 客户端 = AmazonDynamoDBClientBuilder.standard() .withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration("localhost:8000", "ap-southeast-2")) .build( );
  • String tableName = "devtest"; Table table = dynamoDB.createTable(tableName, Arrays.asList(new KeySchemaElement("BIC", KeyType.HASH)), // 排序键 Arrays.asList(new AttributeDefinition("BIC", ScalarAttributeType.S)) new ProvisionedThroughput(10L , 10L)); table.waitForActive();如果我使用上面的代码,则表正在成功创建
  • 谁能帮我解决这个问题

标签: java amazon-web-services amazon-ec2 aws-lambda amazon-dynamodb


【解决方案1】:

只能有一个属性BIC,因为这是你的HASH。由于您没有任何排序键、本地或全局二级索引,因此您无法定义任何其他属性。

DynamoDB 无模式,这意味着它没有任何自定义结构。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-23
    • 1970-01-01
    • 2018-10-11
    • 1970-01-01
    • 2021-12-27
    • 1970-01-01
    相关资源
    最近更新 更多