简体   繁体   English

无法连接到本地 DynamoDB

[英]Cannot connect to local DynamoDB

I cannot connect to DynamoDB that is running local using cli.我无法连接到使用 cli 在本地运行的 DynamoDB。

aws dynamodb list-tables --endpoint-url http://localhost:8000

Could not connect to the endpoint URL: "http://localhost:8000/"无法连接到端点 URL:“http://localhost:8000/”

This doesn't work either: aws dynamodb list-tables --region local Could not connect to the endpoint URL: "http://localhost:8000/"这也不起作用: aws dynamodb list-tables --region local无法连接到端点 URL:“http://localhost:8000/”

I tried using a different port and that didn't help.我尝试使用不同的端口,但没有帮助。 I disabled all proxies too.我也禁用了所有代理。 I am able to connect to DynamoDB using an application like this so I know it's not a dynamodb issue: aws dynamodb list-tables --endpoint-url http://dynamodb.us-west-2.amazonaws.com --region us-west-2我可以使用这样的应用程序连接到 DynamoDB,所以我知道这不是 dynamodb 问题: aws dynamodb list-tables --endpoint-url http://dynamodb.us-west-2.amazonaws.com --region us-west-2

{ "TableNames": [ "Music" ] } {“表名”:[“音乐”]}

When you run当你跑

java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb

command from your terminal make sure output will be like below and no service will be running on port 8000:来自终端的命令确保 output 如下所示,并且端口 8000 上不会运行任何服务:

Initializing DynamoDB Local with the following configuration:
Port:   8000
InMemory:       false
DbPath: null
SharedDb:       true
shouldDelayTransientStatuses:   false
CorsParams:     *

It means, this service running successfully on port 8000.这意味着,该服务在端口 8000 上成功运行。

DynamoDB requires any/fake credentials to work. DynamoDB 需要任何/伪造的凭据才能工作。

AWS Access Key ID: "fakeMyKeyId"
AWS Secret Access Key: "fakeSecretAccessKey"

then try below command to list tables.然后尝试以下命令列出表格。

aws dynamodb list-tables --endpoint-url http://localhost:8000

The error in your logs is the key here Caused by: java.lang.UnsatisfiedLinkError: no sqlite4java-osx-x86_64 in java.library.path: [.]日志中的错误是这里的关键Caused by: java.lang.UnsatisfiedLinkError: no sqlite4java-osx-x86_64 in java.library.path: [.]

This means that the specific dependency cannot be located.这意味着无法定位特定的依赖关系。

The link that Saranjeet provided has a few solutions. Saranjeet 提供的 链接有一些解决方案。 I prefer this solution for testing:我更喜欢这个解决方案进行测试:

First, you need to download the zip file from offcial website. Unzip the file, copy all the *.dll, *.dylib, *.so to a folder under your project root. Say, src/test/resources/libs.
Then, add the code

System.setProperty("sqlite4java.library.path", "src/test/resources/libs/");
before you initialize a local instance of AmazonDynamoDB.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM