spring - 兼容版本 spring cloud、r2dbc

标签 spring spring-boot spring-cloud r2dbc spring-data-r2dbc

我尝试将 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}"
    }
}

当调用存储库的 findAll 时,会发生此错误

java.lang.NoSuchMethodError: org.springframework.transaction.reactive.TransactionSynchronizationManager.currentTransaction()Lreactor/core/publisher/Mono;

快照的更新版本似乎修复了有关事务的问题

最佳答案

问题出在 M1 spring-data-r2dbc 中,由 spring-boot-starter-data-r2dbc0.1.0.M1 提供code> - 您现在需要使用快照构建。

所以改变:

implementation 'org.springframework.boot.experimental:spring-boot-starter-data-r2dbc:0.1.0.M1'

至:

implementation 'org.springframework.boot.experimental:spring-boot-starter-data-r2dbc:0.1.0.BUILD-SNAPSHOT'

...你应该可以开始了。

值得注意的是,至少在撰写本文时,关系 react 性的东西(任何基于 r2dbc 的东西)是非常前沿的东西,根本不能在生产中使用;这自然意味着需要快照构建来解决不时出现的错误和不稳定问题。这在未来可能会改变。

关于spring - 兼容版本 spring cloud、r2dbc,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56857677/

相关文章:

spring-cloud - NetflixOSS Zuul筛选器拒绝请求

java - 配置 Spring 使用多个数据源

java - tomcat 服务器启动后自动导航到 url 的 Spring MVC 设置配置

java - 从 Spring EventListener 更新 Vaadin 8 UI

docker - 未能执行 objective-c om.spotify :docker-maven-plugin:0. 4.3:构建异常捕获:HttpHostConnectException:连接到 localhost:2375

Spring Boot : Tomcat redirects to HTTPS 8443, 无论我指定哪个 HTTPS 端口

spring-cloud - Eureka 对等点未同步

java - @enablesns @enablesqs 注解有什么作用(spring cloud aws)?

java - 如何将hibernate映射到JSP View ?

spring-boot - 如何在spring boot(使用netty服务器)中启用websocket消息压缩deflate(使用rsocket协议(protocol))