java - Dynamodb 本地连接被 Java 拒绝
问题描述
我正在尝试将 dynamodb 与现有的 java 项目连接,但我发现以下错误:
com.amazonaws.SdkClientException:无法执行 HTTP 请求:连接到 localhost:9000 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] 失败:连接被拒绝:连接
我在 pom.xml 中添加了以下依赖项
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>DynamoDBLocal</artifactId>
<version>[1.11,2.0)</version>
</dependency>
<repositories>
<repository>
<id>dynamodb-local-oregon</id>
<url>https://s3.eu-central-1.amazonaws.com/dynamodb-local-frankfurt/release</url>
</repository>
</repositories>
DynamoDBProxyServer server = ServerRunner.createServer(new CommandLineInput(new String[] {
"-dbPath",
System.getProperty("user.dir") + File.separator + "target", "-port", port
}));
server.start();
AmazonDynamoDB dynamodb = AmazonDynamoDBClientBuilder.standard()
.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration
("http://localhost:" + port, "us-west-2"))
.withCredentials(new AWSStaticCredentialsProvider(new AWSCredentials() {
@Override
public String getAWSAccessKeyId() {
return "foo";
}
@Override
public String getAWSSecretKey() {
return "bar";
}
}))
.build();
DynamoDBMapper mapper = new DynamoDBMapper(dynamodb);
CreateTableRequest req = mapper.generateCreateTableRequest(DocumentDescriptor.class);
// Table provision throughput is still required since it cannot be specified in your POJO
req.setProvisionedThroughput(new ProvisionedThroughput(5L, 5L));
// Fire off the CreateTableRequest using the low-level client
CreateTableResult result = dynamodb.createTable(req);
System.out.println(result.toString());
当它执行时CreateTableResult result = dynamodb.createTable(req);
,它给了我connection refused error
。
请帮帮我。提前致谢。
解决方案
推荐阅读
- sql - MS Access,从两个表中获取总值
- visual-studio-code - VSCode 键绑定背后是否有系统?
- r - 根据年龄和事件日期计算出生日期
- node.js - 在频道机器人中发送通知
- javascript - 如何使用 ajax 停止刷新整个网页?
- awk - 使用 awk 显示文本而不是打开文件
- docker - WSO2 IOT APIMClientOAuthException 在 Docker 容器中登录设备管理时
- corda - 导入包 net.corda.client.rpc.CordaRPCClient 时出错
- java - Selenium WebDriver - Java - 更改用户代理
- java - 为什么 Jacoco 不包括 java 类?