AmazonDynamoDBClientBuilder.standard cannot be resolved to a type

amazon-dynamodb, aws-sdk

Solution

Can you post your maven.xml?

You should have the following dependency:

<dependency>
    <groupId>com.amazonaws</groupId>
    <artifactId>aws-java-sdk-dynamodb</artifactId>
    <version>1.11.163</version>
</dependency>

Check for the latest version of the archive on mvnrepository [here].

Or alternatively a maven file structured as follows:

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>com.amazonaws</groupId>
            <artifactId>aws-java-sdk-bom</artifactId>
            <version>1.11.166</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependencies>
    <dependency>
        <groupId>com.amazonaws</groupId>
        <artifactId>aws-java-sdk-dynamodb</artifactId>
    </dependency>
</dependencies>

Please note:

This answer was given when there wasn't a 2nd version of the AWS SDK. In AWS SDK v2 your classes are prefixed with `software.amazon.awssdk`. They no longer reside in packages prefixed with `com.amazonaws` as in AWS SDK v1.

Using AWS SDK v2 you can setup your Maven BOM (bill of materials) as follows:

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>software.amazon.awssdk</groupId>
            <artifactId>bom</artifactId>
            <version>2.20.78</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

For the AWS documentation on setting up a Maven project check [here]. For the latest version of the AWS BOM check [here].

Problem

I am trying to follow a basic AWS tutorial for interacting with DynamoDB in a java runtime environment on a AWS serverless setup. However, for some reason eclipse is throwing an error when I try to create a new AmazonDynamoDBClientBuilder I double-checked and I see the proper dependencies documented in POM.xml, however I still keep getting the error "AmazonDynamoDBClientBuilder.standard cannot be resolved to a type" The code: ``` package com.serverless.demo.function; import com.amazonaws.services.lambda.runtime.Context; import com.amazonaws.services.lambda.runtime.RequestHandler; import com.amazonaws.client.builder.AwsClientBuilder; import com.amazonaws.services.dynamodbv2.AmazonDynamoDB; import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClientBuilder; import com.amazonaws.services.dynamodbv2.document.DynamoDB; import com.amazonaws.services.dynamodbv2.document.Table; import com.amazonaws.services.dynamodbv2.model.AttributeDefinition; import com.amazonaws.services.dynamodbv2.model.KeySchemaElement; import com.amazonaws.services.dynamodbv2.model.KeyType; import com.amazonaws.services.dynamodbv2.model.ProvisionedThroughput; import com.amazonaws.services.dynamodbv2.model.ScalarAttributeType; public class HelloWorld implements RequestHandler<String, String> { @Override public String handleRequest(String input, Context context) { AmazonDynamoDB client = new AmazonDynamoDBClientBuilder.standard().build(); } } ```

Original source