I am trying to integrate dynamo db to my spring boot application I have been following this [link][1] to implement the dynamo db into my spring boot application ever time I try to put into my table I get this error "Unable to unmarshall exception response with the unmarshallers provided".I have created my dynamo db table manually by using aws console I have mentioned my code below
Controller
@RestController
public class EmployeeController {
@Autowired
private EmployeeRepository employeeRepository;
@PostMapping("/emp")
public String data(Employee employee){
return employeeRepository.updateData(employee);
}
Service
@Service
public class EmployeeRepository {
public String updateData(Employee employee) {
AmazonDynamoDB client = AmazonDynamoDBClientBuilder.standard().build();
DynamoDB dynamoDB = new DynamoDB(client);
Table table = dynamoDB.getTable("employee");
Item item = new Item()
.withPrimaryKey("employeeId", "1")
.withString("firstName", "micky")
.withString("lastName", "mouse")
.withString("emailId", "mic@gmail.com");
table.putItem(item);
return "OK";
}
}
DynamoDB config
@Configuration
public class DynamoDBConfiguration {
@Bean
public DynamoDBMapper dynamoDBMapper(){
return new DynamoDBMapper(buildAmazonDynamoDb());
}
private AmazonDynamoDB buildAmazonDynamoDb() {
return AmazonDynamoDBClientBuilder
.standard()
.withEndpointConfiguration(
new AwsClientBuilder.EndpointConfiguration("dyno-config")
)
.withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials(
"accessKey","SecretKey"))).build();
}
}
Entity
@Data
@AllArgsConstructor
@NoArgsConstructor
@DynamoDBTable(tableName="employee")
public class Employee {
public String employeeId;
public String firstName;
public String lastName;
public String emailId;
}
The values mentioned in employee entity are of same name as of mu dynamoDB entity.Can anyone help me out what is wrong with my code [1]: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/JavaDocumentAPIItemCRUD.html