我尝试将spring与r2dbc一起使用
这是我的build.gradle
plugins {
id 'org.springframework.boot' version '2.2.0.M4'
id 'java'
}
apply plugin: 'io.spring.dependency-management'
group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
repositories {
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}
ext {
set('springCloudVersion', "Greenwich.SR2")
}
dependencies {
compile('io.jsonwebtoken:jjwt:0.9.1')
//implementation 'io.jsonwebtoken:jjwt:0.9.1'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-webflux'
implementation 'org.springframework.cloud:spring-cloud-starter-config'
implementation 'org.springframework.cloud:spring-cloud-starter-gateway'
implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'
//runtime 'io.r2dbc:r2dbc-pool:0.8.0.M8'
implementation 'io.r2dbc:r2dbc-postgresql:1.0.0.M7'
compile 'io.r2dbc:r2dbc-pool:1.0.0.BUILD-SNAPSHOT'
implementation 'org.springframework.boot.experimental:spring-boot-starter-r2dbc:0.1.0.M1'
implementation 'org.springframework.boot.experimental:spring-boot-starter-data-r2dbc:0.1.0.M1'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'io.projectreactor:reactor-test'
testImplementation 'org.springframework.security:spring-security-test'
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}
调用一次find查找仓库的所有内容时,会发生此错误
java.lang.NoSuchMethodError: org.springframework.transaction.reactive.TransactionSynchronizationManager.currentTransaction()Lreactor / core / publisher / Mono;
将版本更新为快照似乎可以解决有关交易的问题
答案 0 :(得分:0)
问题出在spring-data-r2dbc
的{{1}}提供的M1 0.1.0.M1
中-您现在需要使用快照构建。
所以改变:
spring-boot-starter-data-r2dbc
收件人:
implementation 'org.springframework.boot.experimental:spring-boot-starter-data-r2dbc:0.1.0.M1'
...而且您应该可以参加。
值得一提的是,至少在撰写本文时,关系反应性内容(基于r2dbc的任何内容)都是非常前沿,根本没有在生产中使用。其自然的含义是需要快照构建来时常解决错误和不稳定性。将来这可能会改变。