我尝试使用 spring-boot-starter-data-r2dbc 和 oracle-r2dbc 运行 r2dbc 应用程序,但它给了我一个异常“org.springframework.dao.DataAccessResourceFailureException:无法获得 R2DBC 连接;嵌套异常是 java.lang.IllegalStateException:此发布者不支持多个订阅者”。
这是我的属性文件:
spring.r2dbc.url=r2dbc:oracle:thin://localhost:1521:orcl
spring.r2dbc.username=user
spring.r2dbc.password=password
和 gradle 文件的依赖部分:dependencies {
ktlint 'com.pinterest:ktlint:0.41.0'
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion")
implementation("org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion")
implementation('com.fasterxml.jackson.module:jackson-module-kotlin')
implementation('org.codehaus.janino:janino')
implementation('org.springframework.cloud:spring-cloud-starter-stream-kafka')
implementation('org.springframework.cloud:spring-cloud-stream')
implementation('org.springframework.boot:spring-boot-configuration-processor')
implementation('org.apache.httpcomponents:httpclient:4.5.8')
implementation('org.springframework.retry:spring-retry')
implementation("org.springframework.boot:spring-boot-starter-webflux")
implementation('org.springframework.boot:spring-boot-starter-data-r2dbc')
implementation('com.oracle.database.r2dbc:oracle-r2dbc')
implementation('com.oracle.database.jdbc:ojdbc11:21.1.0.0')
}
这里的部分代码导致错误:message.flatMap { fromMessage ->
Mono
.zip(
listOf(
dimensionAdviserRepository
.findFirstByEntityIdOrderByFromDateDescToDateDesc(message.adviserKey)
.map { it?.adviserKey ?: -1L }
.switchIfEmpty(Mono.just(-1L)),
dimensionAccountRepository
.findFirstByEntityIdOrderByFromDateDescToDateDesc(fromMessage.accountKey!!)
.map { it?.account_key ?: -1L }
.switchIfEmpty(Mono.just(-1L))
))}
我是否缺少任何配置或者这是一个已知的限制?
最佳答案
看起来像你自己 opened a ticket在 Oracle R2DBC Github 存储库中,在此问题之后有此确切问题,并得到了答案。
帮助其他有同样问题的人:
这是 Oracle R2DBC 0.1.0 版的已知限制。
它已在版本 0.2.0 中修复,但该版本针对 R2DBC SPI 版本 0.9,Spring Data R2DBC 目前不支持该版本,因为它还没有正式发布。
R2DBC SPI 0.9 版的 GA 版本是 planned for 2021-12-06之后,我们可以期待 Spring Data R2DBC 实现对它的支持,使得升级 Oracle R2DBC 驱动程序和摆脱这个限制成为可能。
关于java - 获取 R2DBC 失败,此发布者不支持多订阅者,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68995191/