首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >正在尝试连接到交流发电机(DynamoDB模拟器)

正在尝试连接到交流发电机(DynamoDB模拟器)
EN

Stack Overflow用户
提问于 2013-05-27 20:14:07
回答 2查看 681关注 0票数 0

我正在尝试设置alternatorDB以开发基于DynamoDB的应用程序,但在尝试建立连接时遇到此错误:我已经提供了以下项目的代码、错误和pom.xml。Alternator正在作为独立的服务运行。

我之所以使用取消的Amazon SDK,是因为Alternator DB客户端似乎不接受来自新的SDK com.amazonaws.services.dynamodbv2的对象

顺便说一下,我对Amazon和Maven完全不熟悉。请务必指出所提供的描述是否不充分或不具体。谢谢!

源代码:

代码语言:javascript
运行
复制
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);

错误:

代码语言:javascript
运行
复制
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:

代码语言:javascript
运行
复制
<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>

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-05-29 04:22:05

代码中有两个bugs

  1. 字符串标量类型仅由字符S表示
  2. 键架构元素不包括在表定义中。

这是固定的代码-

代码语言:javascript
运行
复制
    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);
票数 1
EN

Stack Overflow用户

发布于 2013-09-18 04:57:08

相反,您可以在本地运行Amazon DynamoDB,并以轻松的方式模拟您的工作

http://aws.typepad.com/aws/2013/09/dynamodb-local-for-desktop-development.html

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16772987

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档