Java 部署期间发生IllegalStateException:类型上的运算符需要集合参数
我想创建这个Spring数据存储库: API端点使用:Java 部署期间发生IllegalStateException:类型上的运算符需要集合参数,java,spring,spring-data-jpa,spring-data,Java,Spring,Spring Data Jpa,Spring Data,我想创建这个Spring数据存储库: API端点使用: 你知道如何解决这个问题吗?规范和派生规范不能一起工作,请在规范中加入条款。你能告诉我如何修改代码吗?你为什么使用规范还不清楚?您是否编写了任何在repo方法中传递的规范?是的,当我这样使用它时Page findAllByTypeIn(规范规范,Pageable Pageable)它在工作为什么不使用@Spec(path=“types”,Spec=In.class)之类的东西? @GetMapping("find")
你知道如何解决这个问题吗?规范和派生规范不能一起工作,请在规范中加入条款。你能告诉我如何修改代码吗?你为什么使用规范还不清楚?您是否编写了任何在repo方法中传递的规范?是的,当我这样使用它时
Page findAllByTypeIn(规范规范,Pageable Pageable)代码>它在工作为什么不使用@Spec(path=“types”,Spec=In.class)之类的东西?
@GetMapping("find")
public Page<CustomersFullDTO> getAllBySpecification(
@And({
@Spec(path = "status", spec = In.class),
}) Specification<Users> specification,
Pageable pageable
) {
return customersService.getAllBySpecification(specification, pageable)
.map(g -> CustomersFullDTO.builder()
.id(g.getId())
......
.build()
);
}
public interface CustomersService {
Page<Users> findAll(int page, int size);
Page<Users> getAllBySpecification(final Specification<Users> specification, final Pageable pageable);
}
@Override
public Page<Users> findAll(int page, int size) {
return dao.findAllByTypeIn(PageRequest.of(page, size), "CustomerUser");
}
@Override
public Page<Users> getAllBySpecification(Specification<Users> specification, Pageable pageable) {
return this.dao.findAllByTypeIn(specification, pageable, List.of("CustomerUser"));
}
@Repository
public interface CustomersRepository extends JpaRepository<Users, Integer>, JpaSpecificationExecutor<Users> {
Page<Users> findAllByTypeIn(Pageable page, String... types);
Page<Users> findAllByTypeIn(Specification<Users> specification, Pageable pageable, List<String> types);
}
Caused by: java.lang.IllegalStateException: Operator IN on type requires a Collection argument, found interface org.springframework.data.jpa.domain.Specification in method public abstract org.springframework.data.domain.Page org.engine.plugin.production.service.CustomersRepository.findAllByTypeIn(org.springframework.data.jpa.domain.Specification,org.springframework.data.domain.Pageable,java.util.List).