与 Java 的 Dynamodb 本地连接

Dynamodb Local Connection with Java

import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.BasicAWSCredentials;
import com.google.inject.PrivateModule;
import com.google.inject.Provides;
import com.google.inject.Singleton;

 @Singleton
 public class AwsCredentialsModule extends PrivateModule {
   private final String m_accessKeyId;
   private final String m_secretKey;

   public AwsCredentialsModule() {
     m_accessKeyId = "youraccesskey";
     m_secretKey = "yoursecretkey";
  }

   @Override
   protected void configure() {
       expose(AWSCredentials.class);
   }

   @Provides
   @Singleton
   private AWSCredentials provideAmazonCredentials() {
        return new BasicAWSCredentials(m_accessKeyId, m_secretKey);
   }
 }

适用于 Dynamodb 数据库。我正在尝试连接 dynamodb-local 数据库。 在这里,我们使用 MAVEN 和 Google Juice 构建应用程序,并使用 Google Protobuffer 进行接口。 请找到使用相同框架公开 Dynamodb Local 模块的方法。

您没有显示 DynamoDBClient 的定义。 当您想在本地工作时,这就是您 "switch" 需要的元素。

AmazonDynamoDBClient amazonDynamoDBClient = new AmazonDynamoDBClient(CredentialsManager.dummyCreds);

amazonDynamoDBClient.setEndpoint("http://localhost:8000");