当我尝试put
在这个实体上运行代码时。我收到@DynamoDBTyped 或@DynamoDBTypeConverted 的错误,但我可以使用从数据库中检索数据get
并且delete
没有任何问题,我认为问题出在我试图传递给amazon dynamodb 的对象上
@AllArgsConstructor
@NoArgsConstructor
@DynamoDBTable(tableName = "test1")
class Test1{
private String prime
private String lastname
@DynamoDBHashKey(attributeName = "prime")
String getPrime() {
return prime
}
void setPrime(String prime) {
this.prime = prime
}
@DynamoDBAttribute(attributeName = "lastname")
String getLastname() {
return lastname
}
void setLastname(String lastname) {
this.lastname = lastname
}
@Override
String toString() {
return "Test1 [prime=" + prime + ", lastname=" + lastname +"]"
}
}
和控制器类
Test1 getTest1(@PathVariable("prime") String prime) {
return Test1Repository.getTest1ByPrime(prime)
}
和存储库类
class Test1Repository {
@Autowired
private DynamoDBMapper dynamoDBMapper
Test1 save(Test1 test1) {
dynamoDBMapper.save(test1)
return test1
}
错误是
com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMappingException: not supported; requires @DynamoDBTyped or @DynamoDBTypeConverted
at com.amazonaws.services.dynamodbv2.datamodeling.StandardModelFactories$Rules$NotSupported.set(StandardModelFactories.java:664) ~[aws-java-sdk-dynamodb-1.12.48.jar:na]
at com.amazonaws.services.dynamodbv2.datamodeling.StandardModelFactories$Rules$NotSupported.set(StandardModelFactories.java:650) ~[aws-java-sdk-dynamodb-1.12.48.jar:na]
at com.amazonaws.services.dynamodbv2.datamodeling.StandardModelFactories$AbstractRule.convert(StandardModelFactories.java:709) ~[aws-java-sdk-dynamodb-1.12.48.jar:na]
at com.amazonaws.services.dynamodbv2.datamodeling.StandardModelFactories$AbstractRule.convert(StandardModelFactories.java:691) ~[aws-java-sdk-dynamodb-1.12.48.jar:na]
at com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapperFieldModel.convert(DynamoDBMapperFieldModel.java:138) ~[aws-java-sdk-dynamodb-1.12.48.jar:na]
at com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper$SaveObjectHandler.execute(DynamoDBMapper.java:738) ~[aws-java-sdk-dynamodb-1.12.48.jar:na]
at com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper.save(DynamoDBMapper.java:640) ~[aws-java-sdk-dynamodb-1.12.48.jar:na]
at com.amazonaws.services.dynamodbv2.datamodeling.AbstractDynamoDBMapper.save(AbstractDynamoDBMapper.java:123) ~[aws-java-sdk-dynamodb-1.12.48.jar:na]
at com.amazonaws.services.dynamodbv2.datamodeling.IDynamoDBMapper$save.call(Unknown Source) ~[na:na]
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47) ~[groovy-3.0.8.jar:3.0.8]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125) ~[groovy-3.0.8.jar:3.0.8]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:139) ~[groovy-3.0.8.jar:3.0.8]