使用 ReactiveCouchbaseRepository 时出现 IllegalArgumentException 预期会找到 class rxSingle 的反应适配器,但找不到
IllegalArgumentException while using ReactiveCouchbaseRepository Expected to find reactive adapter for class rxSingle but couldnt
我正在开发 reactive application that uses Springboot WebFlux 框架和 Couchbase 数据库。
Spring 为 Couchbase 提供 JPA 实现,我的存储库界面如下所示。
@Repository
public interface ExampleRepository extends ReactiveCouchbaseRepository<Example, String> {
}
并且我以这种方式在 Spring 配置(基于 Java)文件中启用反应式 Couchbase 存储库
@Configuration
@EnableReactiveCouchbaseRepositories(basePackages = { "com.examples.repository" })
public class CouchDatabaseConfig extends AbstractCouchbaseConfiguration {
当我尝试通过调用存储库的 findById() 方法从数据库中检索数据时,出现以下异常。
java.lang.IllegalArgumentException: Expected to find reactive adapter for class rx.Single but couldn't!
我花了很多时间来弄清楚为什么会出现此异常,因为没有其他 Google 搜索结果帮助我解决问题。我在这里发布解决方案,希望它能对像我这样的人有所帮助。
原因
Either you have not included the dependency for reactive streams or you have included an incompatible one.
将此行添加到我的 build.gradle 中挽救了我的生命。
compile('io.reactivex:rxjava-reactive-streams')
我正在开发 reactive application that uses Springboot WebFlux 框架和 Couchbase 数据库。 Spring 为 Couchbase 提供 JPA 实现,我的存储库界面如下所示。
@Repository
public interface ExampleRepository extends ReactiveCouchbaseRepository<Example, String> {
}
并且我以这种方式在 Spring 配置(基于 Java)文件中启用反应式 Couchbase 存储库
@Configuration
@EnableReactiveCouchbaseRepositories(basePackages = { "com.examples.repository" })
public class CouchDatabaseConfig extends AbstractCouchbaseConfiguration {
当我尝试通过调用存储库的 findById() 方法从数据库中检索数据时,出现以下异常。
java.lang.IllegalArgumentException: Expected to find reactive adapter for class rx.Single but couldn't!
我花了很多时间来弄清楚为什么会出现此异常,因为没有其他 Google 搜索结果帮助我解决问题。我在这里发布解决方案,希望它能对像我这样的人有所帮助。
原因
Either you have not included the dependency for reactive streams or you have included an incompatible one.
将此行添加到我的 build.gradle 中挽救了我的生命。
compile('io.reactivex:rxjava-reactive-streams')