大家好,我有一个表名为test
. 我有一个像这样的 grails 控制器:
def ec2Test = {
def tableName = new DescribeTableRequest()
tableName.setTableName("test")
def createdTable = amazonWebService.dynamoDB.describeTable(tableName)
}
但是当我尝试点击这个控制器时,我得到:
Requested resource not found: Table: Anto_Testing_Table not found
尽管我可以在浏览器中看到test
aws dynamo DB 中有一个可用的表名。在我的 grailsconfig.groovy
中,我也添加了以下几行:
grails.plugin.awssdk.accessKey = "xxxxxxx"
grails.plugin.awssdk.secretKey = "xxxxxxx"
grails.plugin.awssdk.region = "ap-southeast-1"
我在哪里犯错误?我也尝试创建表,并打印结果,它看起来像这样:
{TableName: Testing table, KeySchema: {HashKeyElement: {AttributeName: name, AttributeType: S, }, }, TableStatus: CREATING, CreationDateTime: Mon Oct 01 12:23:37 IST 2012, ProvisionedThroughput: {ReadCapacityUnits: 10, WriteCapacityUnits: 10, }, }
我等了大约15分钟。并刷新浏览器,我无法看到尚未创建的表!我用于创建表的代码是:
String tableName = "Testing Table";
CreateTableRequest createTableRequest = new CreateTableRequest().withTableName(tableName)
.withKeySchema(new KeySchema(new KeySchemaElement().withAttributeName("name").withAttributeType("S")))
.withProvisionedThroughput(new ProvisionedThroughput().withReadCapacityUnits(10L).withWriteCapacityUnits(10L));
TableDescription createdTableDescription = amazonWebService.dynamoDB.createTable(createTableRequest).getTableDescription();
println createdTableDescription
提前致谢。