【发布时间】:2020-09-28 01:55:30
【问题描述】:
将规范传递给 repository.findAll() 时遇到问题
Version:spring-boot-starter-data-jpa-2.2.4.RELEASE
存储库
@Repository
public interface ServerAttributesRepository extends JpaRepository<ServerAttributes, Integer>{
public ServerAttributes findById(int Id);
}
当我通过传递规范调用 repository.findAll 时,我得到错误
ServerAttributeSpecification spec1 = new ServerAttributeSpecification(
new SearchCriteria("server", SearchOperation.EQUALITY, "1"));
List<ServerAttributes> serverAttributesList = serverAttributesRepository.findAll(spec1);
错误:
Cannot resolve method 'findAll(com.cloud.compareService.specification.ServerAttributeSpecification)'
我在我的 JpaRepository 中找不到 findAll(Specification<T> spec)
参考:https://www.baeldung.com/rest-api-query-search-language-more-operations
【问题讨论】:
-
请不要包含代码截图。
标签: java spring spring-data spring-repositories