Spring 如何使用卷曲从弹簧靴积垢中计数?
我对回购有一个简单的定义:Spring 如何使用卷曲从弹簧靴积垢中计数?,spring,spring-boot,count,crud,spring-data-rest,Spring,Spring Boot,Count,Crud,Spring Data Rest,我对回购有一个简单的定义: public interface StorageService extends CrudRepository<Car, Long> {} 基本上,我使用的是来自的save()和findAll()方法 如何使用curl调用count()方法,curl也在crudepository中定义(没有定义其他服务)我认为这是不可能的 在我看来(可能我错了),这是因为SpringDataREST基本上是通过HTTP方法(GET、POST等)提供rest端点,用于对资源
public interface StorageService extends CrudRepository<Car, Long> {}
基本上,我使用的是来自的save()
和findAll()
方法
如何使用curl调用
count()
方法,curl也在crudepository
中定义(没有定义其他服务)我认为这是不可能的
在我看来(可能我错了),这是因为SpringDataREST基本上是通过HTTP方法(GET、POST等)提供rest端点,用于对资源(实体)执行操作,而GET计数不是HTTP操作
但是你可以通过其他两种方式来实现这一点
carcountbymodel(字符串模型)代码>
@查询
工作正常。这与Spring提取所有数据源上的数据的方式相同吗?如果实体类中有一个名为model
的字段,countByModel也应该可以工作。我不知道我是否理解你问题的第二部分我想数一数。不是通过过滤器。谢谢
curl -v http://localhost:8080/cars
curl -i -X POST -H "Content-Type:application/json" -d '{"licensePlate" : "Vegan is Moral" }' http://localhost:8080/cars
@Query("select count(*) from Car")
long getCount();