title: How to pass aws dynamodb table name dynamically using @DynamoDbTable annotation
body: <p>I have created a java service to get the details from dynamodb it is working fine but my challenge is i hardcoded the table name to the class file <strong>@DynamoDbTable</strong> annotation in order to work with different environments i feel it is not the right way. I have given my code below could someone help me to resolve the issue.</p>
  <p><strong>Code sample</strong></p>
  <pre><code>public class DynamodbService {
  
      private DynamoDB client;
      private DynamoDBMapper objectMapper;
  
      /**
       * 
       * @param client
       * @param objectMapper
       */
      @Autowired
      public DynamodbService(DynamoDB client, DynamoDBMapper objectMapper) {
          this.client = client;
          this.objectMapper = objectMapper;
      }
  
  
      public List&lt;Dynamodb&gt; findAll() throws Exception {
          DynamoDBMapperConfig mapperConfig = new DynamoDBMapperConfig.Builder()
                  .withTableNameOverride(DynamoDBMapperConfig.TableNameOverride.withTableNameReplacement(&quot;&quot;))
                  .build();
          DynamoDBMapper mapper = new DynamoDBMapper(client, mapperConfig);
  
          DynamoDBScanExpression scanExpression = new DynamoDBScanExpression();
  
          List&lt;Dynamodb&gt; scanResult = objectMapper.scan(Dynamodb.class, scanExpression);
          return scanResult;
      }
  
  }
  </code></pre>
  <p><strong>My DynamoDB config</strong></p>
  <pre><code>@Configuration
  public class DynamoDBconfig {
      /**
       * 
       */
      @Value(&quot;${amazon.dynamodb.accesskey}&quot;)
      private String awsAccessKey;
      /**
       * 
       */
      @Value(&quot;${amazon.dynamodb.secretkey}&quot;)
      private String awsSecretKey;
  
      
      @Bean
      public AWSCredentials amazonAWSCredentials() {
          return new BasicAWSCredentials(aes.getDecryptedvalue(awsAccessKey), aes.getDecryptedvalue(awsSecretKey));
      }
  
      /**
       * 
       * @return
       */
      @Bean
      public DynamoDBMapperConfig dynamoDBMapperConfig() {
          return DynamoDBMapperConfig.DEFAULT;
      }
  
      /**
       * 
       * @param amazonDynamoDB
       * @param config
       * @return
       */
      @Bean
      public DynamoDBMapper dynamoDBMapper(AmazonDynamoDB amazonDynamoDB, DynamoDBMapperConfig config) {
          return new DynamoDBMapper(amazonDynamoDB, config);
      }
  
      /**
       * 
       * @return
       */
      @Bean
      public AmazonDynamoDB amazonDynamoDB() {
          return AmazonDynamoDBClientBuilder.standard().withCredentials(amazonAWSCredentialsProvider())
                  .withRegion(Regions.US_EAST_2).build();
      }
  
      /**
       * 
       * @return
       */
      @Bean
      public DynamoDB dynamoDB() {
          return new DynamoDB(amazonDynamoDB());
      }
  
      /**
       * 
       * @return
       */
      public AWSCredentialsProvider amazonAWSCredentialsProvider() {
          return new AWSStaticCredentialsProvider(amazonAWSCredentials());
      }
  
  }
  </code></pre>
  <p><strong>ERROR in my dynamodb service</strong></p>
  <blockquote>
  <p>The constructor DynamoDBMapper(DynamoDB, DynamoDBMapperConfig) is undefined</p>
  </blockquote>
  <p>I am unable find out what is the issue. If i use table name in class file it's working fine if i try to replace the table name using code it ends up with error.</p>