简体   繁体   English

兼容版本Spring Cloud,R2DBC

[英]Compatibility version spring cloud, r2dbc

I try to use spring with r2dbc 我尝试在r2dbc中使用spring

here my build.gradle 这是我的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}"
    }
}

When a call is done to findAll of repository, this error happen 调用findAll的存储库时,会发生此错误

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

update version to snapshot seem to fix issue about transaction 将版本更新到快照似乎可以解决有关事务的问题

The issue is in M1 spring-data-r2dbc , provided by 0.1.0.M1 of spring-boot-starter-data-r2dbc - you'll need to use the snapshot builds for now instead. 问题是在M1 spring-data-r2dbc ,提供0.1.0.M1spring-boot-starter-data-r2dbc -你需要使用快照建立,现在来代替。

So change: 所以改变:

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

to: 至:

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

...and you should be good to go. ...而且您应该很好。

Worth noting that, at the time of writing at least, the relational reactive stuff (anything r2dbc based) is very bleeding edge and not at all something to use in production; 值得一提的是,至少在撰写本文时,关系型反应性内容(基于r2dbc的任何内容)都具有非常前沿的优势,根本没有在生产中使用。 the natural implication of that is that snapshot builds are required to work around bugs and instabilities from time to time. 其自然的含义是需要快照构建来时常解决错误和不稳定性。 This will likely change in the future. 将来这可能会改变。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM