我正在尝试在以下spring / dynamoDB应用程序中运行测试。我不确定错误是什么试图告诉我,我只是确定这是一个映射错误。
我正在尝试做的是加载已经在我的AWS Dynamo数据库中说明的项目并拉入一个字符串以在System.out中输出。感谢您提前提供任何帮助。
@Configuration
@EnableDynamoDBRepositories(basePackages = "com.ronone")
public class AWSConfig {
@Value("${amazon.aws.accesskey}")
private String amazonAWSAccessKey;
@Value("${amazon.aws.secretkey}")
private String amazonAWSSecreyKey;
@Bean
public AWSCredentials awsCredentials(){
return new BasicAWSCredentials(amazonAWSAccessKey, amazonAWSSecreyKey);
}
@Bean
public AmazonDynamoDB amazonDynamoDB(AWSCredentials awsCredentials){
AmazonDynamoDB amazonDynamoDB = AmazonDynamoDBClientBuilder.standard()
.withCredentials(new AWSStaticCredentialsProvider(awsCredentials))
.withEndpointConfiguration(
new AwsClientBuilder.EndpointConfiguration("http://localhost:8080", "us-east-2"))
.build();
return amazonDynamoDB;
}
}
控制器
@RestController
public class CountryController {
private DynamoDBMapper dynamoDBMapper;
@Autowired
private AmazonDynamoDB dynamoDB;
@RequestMapping("/")
public String test(){
Country testCountry;
dynamoDBMapper = new DynamoDBMapper(dynamoDB);
testCountry = dynamoDBMapper.load(Country.class, "Algeria");
return "Country was: " + testCountry.getCountryName().toString();
}
}
PrintTrace:
com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMappingException: type [class java.util.UUID] is not supported; no conversion from class java.lang.Long
at com.amazonaws.services.dynamodbv2.datamodeling.StandardTypeConverters$ConverterMap.getConverter(StandardTypeConverters.java:514) ~[aws-java-sdk-dynamodb-1.11.235.jar:na]
at com.amazonaws.services.dynamodbv2.datamodeling.StandardTypeConverters$ConverterMap.access$4800(StandardTypeConverters.java:486) ~[aws-java-sdk-dynamodb-1.11.235.jar:na]
at com.amazonaws.services.dynamodbv2.datamodeling.StandardTypeConverters$Scalar.getConverter(StandardTypeConverters.java:312) ~[aws-java-sdk-dynamodb-1.11.235.jar:na]
at com.amazonaws.services.dynamodbv2.datamodeling.StandardTypeConverters.getConverter(StandardTypeConverters.java:66) ~[aws-java-sdk-dynamodb-1.11.235.jar:na]
at com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBGeneratedUuid$Generator.<init>(DynamoDBGeneratedUuid.java:61) ~[aws-java-sdk-dynamodb-1.11.235.jar:na]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_151]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_151]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_151]
at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[na:1.8.0_151]
at com.amazonaws.services.dynamodbv2.datamodeling.StandardAnnotationMaps.overrideOf(StandardAnnotationMaps.java:436) ~[aws-java-sdk-dynamodb-1.11.235.jar:na]
at com.amazonaws.services.dynamodbv2.datamodeling.StandardAnnotationMaps.access$500(StandardAnnotationMaps.java:42) ~[aws-java-sdk-dynamodb-1.11.235.jar:na]
at com.amazonaws.services.dynamodbv2.datamodeling.StandardAnnotationMaps$TypedMap.autoGenerator(StandardAnnotationMaps.java:164) ~[aws-java-sdk-dynamodb-1.11.235.jar:na]
at com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapperFieldModel$Properties$Immutable.<init>(DynamoDBMapperFieldModel.java:461) ~[aws-java-sdk-dynamodb-1.11.235.jar:na]
at com.amazonaws.services.dynamodbv2.datamodeling.StandardBeanProperties$Bean.<init>(StandardBeanProperties.java:92) ~[aws-java-sdk-dynamodb-1.11.235.jar:na]
at com.amazonaws.services.dynamodbv2.datamodeling.StandardBeanProperties$Bean.<init>(StandardBeanProperties.java:86) ~[aws-java-sdk-dynamodb-1.11.235.jar:na]
at com.amazonaws.services.dynamodbv2.datamodeling.StandardBeanProperties$BeanMap.putOrFlatten(StandardBeanProperties.java:217) ~[aws-java-sdk-dynamodb-1.11.235.jar:na]
at com.amazonaws.services.dynamodbv2.datamodeling.StandardBeanProperties$BeanMap.putAll(StandardBeanProperties.java:207) ~[aws-java-sdk-dynamodb-1.11.235.jar:na]
at com.amazonaws.services.dynamodbv2.datamodeling.StandardBeanProperties$BeanMap.<init>(StandardBeanProperties.java:198) ~[aws-java-sdk-dynamodb-1.11.235.jar:na]
at com.amazonaws.services.dynamodbv2.datamodeling.StandardBeanProperties$CachedBeans.getBeans(StandardBeanProperties.java:55) ~[aws-java-sdk-dynamodb-1.11.235.jar:na]
at com.amazonaws.services.dynamodbv2.datamodeling.StandardBeanProperties$CachedBeans.access$100(StandardBeanProperties.java:48) ~[aws-java-sdk-dynamodb-1.11.235.jar:na]
at com.amazonaws.services.dynamodbv2.datamodeling.StandardBeanProperties.of(StandardBeanProperties.java:42) ~[aws-java-sdk-dynamodb-1.11.235.jar:na]
at com.amazonaws.services.dynamodbv2.datamodeling.StandardModelFactories$TableBuilder.<init>(StandardModelFactories.java:132) ~[aws-java-sdk-dynamodb-1.11.235.jar:na]
at com.amazonaws.services.dynamodbv2.datamodeling.StandardModelFactories$TableBuilder.<init>(StandardModelFactories.java:116) ~[aws-java-sdk-dynamodb-1.11.235.jar:na]
at com.amazonaws.services.dynamodbv2.datamodeling.StandardModelFactories$StandardTableFactory.getTable(StandardModelFactories.java:107) ~[aws-java-sdk-dynamodb-1.11.235.jar:na]
at com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper.getTableModel(DynamoDBMapper.java:393) ~[aws-java-sdk-dynamodb-1.11.235.jar:na]
at com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper.load(DynamoDBMapper.java:431) ~[aws-java-sdk-dynamodb-1.11.235.jar:na]
at com.amazonaws.services.dynamodbv2.datamodeling.AbstractDynamoDBMapper.load(AbstractDynamoDBMapper.java:80) ~[aws-java-sdk-dynamodb-1.11.235.jar:na]
at com.ronone.controller.CountryController.test(CountryController.java:24) ~[classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_151]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_151]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_151]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_151]
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205) ~[spring-web-4.3.13.RELEASE.jar:4.