我正在使用Spring Boot 2和webflux
进行开发。 我尝试使用ReactiveSortingRepository
来简化redis操作。
public interface DataProfileRepository extends ReactiveSortingRepository<DataProfileDTO, String> {
}
只需使用此界面即可。
Mono<DataProfileDTO> tmp = this.dataProfileRepository.findById(id);
异常:
org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [com.tradeshift.dgps.dto.DataProfileDTO] to type [reactor.core.publisher.Mono<?>]
at org.springframework.core.convert.support.GenericConversionService.handleConverterNotFound(GenericConversionService.java:321) ~[spring-core-5.0.2.RELEASE.jar:5.0.2.RELEASE]
at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:194) ~[spring-core-5.0.2.RELEASE.jar:5.0.2.RELEASE]
at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:174) ~[spring-core-5.0.2.RELEASE.jar:5.0.2.RELEASE]
at org.springframework.data.repository.util.ReactiveWrapperConverters.toWrapper(ReactiveWrapperConverters.java:197) ~[spring-data-commons-2.0.2.RELEASE.jar:2.0.2.RELEASE]
at org.springframework.data.repository.core.support.QueryExecutionResultHandler.postProcessInvocationResult(QueryExecutionResultHandler.java:104) ~[spring-data-commons-2.0.2.RELEASE.jar:2.0.2.RELEASE]
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:587) ~[spring-data-commons-2.0.2.RELEASE.jar:2.0.2.RELEASE]
出现了错误。
在调试模式下,我发现该存储库的行为与反应堆不一致。可以看到从Redis中获取了一个实际的DataProfileDTO
,但在尝试时失败了:
GENERIC_CONVERSION_SERVICE.convert(reactiveObject, targetWrapperType);
在ReactiveWrapperConverters.toWrapper
中
我搜索了一下,似乎Spring Data Redis 2.0没有提到响应式存储库支持。我在想是不是我的代码有问题,还是Spring Data Redis 2.0尚未支持ReactiveCrudRepository。