Im trying to accomplish using the Spring Data CrudRepository default crud operations that do not need implementation. None of the operations make it to dynamodb. No exceptions or indicative log messages.
我正在尝试使用不需要实现的Spring data CrudRepository缺省CRUD操作来完成。所有操作都不能到达DynamoDB。没有异常或指示性日志消息。
I've extended the CrudRepository:
我已经扩展了CrudRepository:
@EnableScan
public interface DrinkRepository extends CrudRepository<Drink, String> {
Drink save(Drink drink);
Optional<Drink> findById(String id);
}
Injected the repository into my service:
将存储库注入到我的服务中:
@Service
public class DrinkService {
@Autowired
DrinkRepository drinkRepo;
public Optional<Drink> getDrinksByName(String name){
System.out.println("Line7");
Optional<Drink> drink = drinkRepo.findById("01");
System.out.println(drink);
return drink;
}
public Drink createDrink() {
Drink mockDrink = new Drink("name");
mockDrink.setId("04");
drinkRepo.save(mockDrink);
return mockDrink;
}
Invoking from my controller:
从我的控制器调用:
@PostMapping("/saveDrink")
public Drink createDrink() {
return drinkService.createDrink();
}
My dynamodb connection:
我的DynamoDB连接:
@Bean
public AmazonDynamoDB amazonDynamoDB() {
AmazonDynamoDB amazonDynamoDB
= new AmazonDynamoDBClient(amazonAWSCredentials());
if (!StringUtils.isEmpty(dynamoDbEndpoint)) {
amazonDynamoDB.setEndpoint(dynamoDbEndpoint);
}
return amazonDynamoDB;
}
@Bean
public AWSCredentials amazonAWSCredentials() {
return new BasicAWSCredentials(
awsAccessKey, awsSecretKey);
}
更多回答
优秀答案推荐
我是一名优秀的程序员,十分优秀!