我尝试使用本地安装的DynamoDb(每this)。我打开了Web UI(http://localhost:8000/shell
)并创建了几个表,可以使用Web UI查看它们。
如果我尝试使用cmd行或简单的java应用程序查看这些相同的表,我看不到它们。
Cmd line:aws dynamodb list-tables --endpoint-url http://localhost:8000
爪哇:
AmazonDynamoDBClient client = new AmazonDynamoDBClient().withEndpoint("http://localhost:8000");
public void listMyTables() {
TableCollection<ListTablesResult> tables = dynamoDB.listTables();
Iterator<Table> iterator = tables.iterator();
System.out.println("Listing table names");
while (iterator.hasNext()) {
Table table = iterator.next();
System.out.println(table.getTableName());
}
}
我尝试按以下方式添加凭据:
DynamoDB dynamoDB = new DynamoDB(new AmazonDynamoDBClient(
new ClasspathPropertiesFileCredentialsProvider("credentials")).withEndpoint("http://localhost:8000"));
进一步混淆问题:如果我使用cmdline创建一个表,我可以看到它使用上面的cmdline而不是通过WebUI或Java显示。
那么:我做出了多么明显的错误?
我很确定所有三种方法都在查看本地数据库,因为如果我停止它们就会出错。
答案 0 :(得分:0)
我想我想出来了。如果您按如下方式启动本地数据库实例:
java -Djava.library.path =。/ DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb
它在UI,cmd行和Java之间起作用。请注意cmd行的var exSchema = `
type Mutation {
addUser(
name: String!
favMovies: [{ movie: String! #ref to movies coll
personal_rating: Int! # this is different for every movie
}]
) : User
}
...
`
部分。我相信本地shell会在&#34;地区启动。除非你用你的命令指定区域(或使用上面的参数来否定区域),否则你将遇到我在上面看到的内容。