我正在尝试将DynamoDB在本地集成到我的Spring Boot项目中。 它曾经与Spring Data JPA一起使用,现在我试图切换到Spring Data Dynamo DB
我将此行添加到属性文件中
spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults = false
存储库:
@EnableScan
public interface TransactionRepository extends CrudRepository<Transaction, Long> {
}
实体定义
@DynamoDBTable(tableName = "Transaction")
public class Transaction {
private long id;
/**
* Transaction category
*/
Category category;
/** Transaction amount */
double amount;
@DynamoDBAttribute
public Category getCategory() {
return category;
}
public void setCategory(Category category) {
this.category = category;
}
@DynamoDBAttribute
public double getAmount() {
return amount;
}
public void setAmount(double amount) {
this.amount = amount;
}
@DynamoDBHashKey
@DynamoDBAutoGeneratedKey
public long getId() {
return id;
}
Transaction() {
this.setAmount(0);
this.setCategory(Category.OTHER);
}
public Transaction(double amount, Category category) {
this.setAmount(amount);
this.setCategory(category);
}
}