我正在尝试设置alternatorDB以开发基于DynamoDB的应用程序,但在尝试建立连接时遇到此错误:我已经提供了以下项目的代码、错误和pom.xml。Alternator正在作为独立的服务运行。
我之所以使用取消的Amazon SDK,是因为Alternator DB客户端似乎不接受来自新的SDK com.amazonaws.services.dynamodbv2的对象
顺便说一下,我对Amazon和Maven完全不熟悉。请务必指出所提供的描述是否不充分或不具体。谢谢!
源代码:
this.client = new AlternatorDBClient();
// Create a table with a primary key named 'name', which holds a string
ProvisionedThroughput thorughput = new ProvisionedThroughput().withReadCapacityUnits(10L).withWriteCapacityUnits(5L);
KeySchemaElement schemaElement = new KeySchemaElement().withAttributeName("Name").withAttributeType("String");
CreateTableRequest createTableRequest = new CreateTableRequest().withTableName(TOPIC_TABLE).withProvisionedThroughput(thorughput);
client.createTable(createTableRequest);
错误:
Exception in thread "main" AmazonServiceException: Status Code: 400, AWS Service: AmazonDynamoDB, AWS Request ID: null, AWS Error Code: AmazonServiceException, AWS Error Message: [java.lang.Error: property value is null.]
at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:644)
at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:338)
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:190)
at com.michelboudreau.alternator.AlternatorDBClient.invoke(AlternatorDBClient.java:212)
at com.michelboudreau.alternator.AlternatorDBClient.createTable(AlternatorDBClient.java:137)
at Main.run(Main.java:35)
at Main.main(Main.java:23)
下面是该项目的pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.project</groupId>
<artifactId>AlternatorTest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>AlternatorTest</name>
<dependencies>
<dependency>
<groupId>com.michelboudreau</groupId>
<artifactId>alternator</artifactId>
<version>0.5.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk</artifactId>
<version>1.4.4.2</version>
</dependency>
</dependencies>
<repositories>
<repository>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
<id>sonatype-nexus</id>
<url>https://oss.sonatype.org/content/groups/public</url>
</repository>
</repositories>
发布于 2013-05-29 04:22:05
代码中有两个bugs
这是固定的代码-
ProvisionedThroughput thorughput = new ProvisionedThroughput().withReadCapacityUnits(10L).withWriteCapacityUnits(5L);
KeySchemaElement schemaElement = new KeySchemaElement().withAttributeName("Name").withAttributeType(ScalarAttributeType.S);
CreateTableRequest createTableRequest = new CreateTableRequest().withTableName(TOPIC_TABLE).withProvisionedThroughput(thorughput).withKeySchema(new KeySchema(schemaElement));
client.createTable(createTableRequest);
发布于 2013-09-18 04:57:08
相反,您可以在本地运行Amazon DynamoDB,并以轻松的方式模拟您的工作
http://aws.typepad.com/aws/2013/09/dynamodb-local-for-desktop-development.html
https://stackoverflow.com/questions/16772987
复制相似问题