我正在使用$ clang++-5.0 -Wall -std=c++17 auto_param.cxx && ./a.out
zero_as_uint: std::integral_constant<unsigned int, 0u>
zero_as_int: std::integral_constant<int, 0>
玩Spring Boot 2。我正在尝试使用webflux
来简化redis操作。
ReactiveSortingRepository
只需使用此界面
即可public interface DataProfileRepository extends ReactiveSortingRepository<DataProfileDTO, String> {
}
异常:
Mono<DataProfileDTO> tmp = this.dataProfileRepository.findById(id);
被抛出。
此存储库的行为与reactor不匹配,我可以在调试模式中看到,从redis获取实际的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]
。在尝试:
DataProfileDTO
GENERIC_CONVERSION_SERVICE.convert(reactiveObject, targetWrapperType);
中的
我去谷歌搜索,似乎Spring Data Redis 2.0没有提到反应式存储库支持。我想知道我的代码或Spring Data Redis 2.0中是否有任何错误,我还不支持ReactiveCrudRepository。
答案 0 :(得分:3)
根据Spring的Reactive Redis Support文档,与Redis进行反应性支持的最高抽象级别是ReactiveRedisTemplate
。 ReactiveRedisConnection
是较低的抽象,与二进制值(ByteBuffer)一起用作输入和输出。
没有提到对反应性存储库的支持。 您也可以参考spring-data github repo中的官方反应示例。
为了使所有这些工作正常,您需要在您正在使用的驱动程序中获得反应支持 - 目前这将是lettuce。
虽然不理想,但另一种选择是Flux.fromIterable()
。您可以使用阻塞存储库并以反应方式处理结果。
public interface DataProfileRepository extends CrudRepository<DataProfileDTO, String> {
}
并包装它:
Flux.fromIterable(dataProfileRepository.findById(id)), DataProfileDTO.class))