spring数据中的ReactiveCouchbaseSortingRepository,用于沙发床反应式,不允许在Pageable
查询中使用find
参数
我有一个名为MyEntity
的pojo,如下所示。
当我在下面不使用Pageable
的情况下运行第二个查找查询时,它会正确返回响应,但是当我使用Pageable
参数运行时,则在初始化应用程序时它将抛出以下异常。
Caused by: java.lang.IllegalStateException: Method has to have one of the following return types! [interface org.springframework.data.domain.Page, interface java.util.List, interface org.springframework.data.domain.Slice]
尽管它应该按照参考文档以及适用于MongoDb的方式工作
how-apply-pagination-in-reactive-spring-data
public class MyEntity {
@Id
private String id;
private Instant effectiveDateTime;
private String createdBy;
private Instant createdDateTime;
}
public interface EntityRepository extends ReactiveCouchbaseSortingRepository<MyEntity, String> {
Flux<MyEntity> findByEffectiveDateTimeBetween(Instant start, Instant end, Pageable pageable) ;
Flux<MyEntity> findByEffectiveDateTimeBetween(Instant start, Instant end) ;
}
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'EntityRepository': Invocation of init method failed; nested exception is java.lang.IllegalStateException: Method has to have one of the following return types! [interface org.springframework.data.domain.Page, interface java.util.List, interface org.springframework.data.domain.Slice]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1745) ~[spring-beans-5.1.4.RELEASE.jar:5.1.4.RELEASE]
caused by: java.lang.IllegalStateException: Method has to have one of the following return types! [interface org.springframework.data.domain.Page, interface java.util.List, interface org.springframework.data.domain.Slice]
at org.springframework.data.repository.query.QueryMethod.assertReturnTypeAssignable(QueryMethod.java:301) ~[spring-data-commons-2.1.4.RELEASE.jar:2.1.4.RELEASE]
at org.springframework.data.repository.query.QueryMethod.<init>(QueryMethod.java:86) ~[spring-data-commons-2.1.4.RELEASE.jar:2.1.4.RELEASE]
at org.springframework.data.couchbase.repository.query.CouchbaseQueryMethod.<init>(CouchbaseQueryMethod.java:47) ~[spring-data-couchbase-3.1.4.RELEASE.jar:3.1.4.RELEASE]
at org.springframework.data.couchbase.repository.support.ReactiveCouchbaseRepositoryFactory$CouchbaseQueryLookupStrategy.resolveQuery(ReactiveCouchbaseRepositoryFactory.java:222) ~[spring-data-couchbase-3.1.4.RELEASE.jar:3.1.4.RELEASE]
进一步阅读时,似乎是spring数据共享库中的错误。
因为弹簧数据中用于检查返回类型的类QueryExecutionConverters.java
在其列表中不包含Flux
或任何响应类型。
有人可以确认它的文档错误还是spring数据公用程序中的代码错误。
ALLOWED_PAGEABLE_TYPES.add(Slice.class);
ALLOWED_PAGEABLE_TYPES.add(Page.class);
ALLOWED_PAGEABLE_TYPES.add(List.class);