簡體   English   中英

使用 r2dbc 配置進行 liquibase 初始化

[英]liquibase initialization with r2dbc config

嘗試使用 r2dbc 和 init 數據庫運行 spring 引導。 我的 build.gradle 看起來像:

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-data-r2dbc'
    implementation 'org.springframework.boot:spring-boot-starter-webflux'
    implementation 'org.liquibase:liquibase-core'

    compileOnly 'org.projectlombok:lombok'

    runtimeOnly 'org.liquibase:liquibase-core'
    runtimeOnly 'com.h2database:h2'
    runtimeOnly 'io.r2dbc:r2dbc-h2'
    runtimeOnly 'io.r2dbc:r2dbc-postgresql'
    runtimeOnly 'org.postgresql:postgresql'

    annotationProcessor 'org.projectlombok:lombok'

    testImplementation 'org.springframework.boot:spring-boot-starter-test'
    testImplementation 'io.projectreactor:reactor-test'
}

Spring 屬性:

spring.r2dbc.url=r2dbc:postgresql://127.0.0.1:5432/test
spring.r2dbc.username=postgres
spring.r2dbc.password=123
spring.r2dbc.pool.enabled=true
spring.r2dbc.pool.initial-size=10
spring.data.r2dbc.repositories.enabled=true

spring.liquibase.change-log=classpath:/db/changelog/db.changelog-master.yaml
spring.liquibase.url=jdbc:postgresql://127.0.0.1:5432/test
spring.liquibase.user=postgres
spring.datasource.driver-class-name=org.postgresql.Driver
logging.level.liquibase = INFO

開始后它與

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [liquibase.integration.spring.SpringLiquibase]: Factory method 'liquibase' threw exception; nested exception is java.lang.NoClassDefFoundError: org/springframework/jdbc/datasource/SimpleDriverDataSource

我做錯了什么?

您需要添加對org.springframework:spring-jdbc的依賴。 來自Spring 引導參考文檔

或者,您可以配置 Flyway 或 Liquibase 以在遷移期間為您配置 DataSource。 這兩個庫都提供屬性來設置 url、要遷移的數據庫的用戶名和密碼。

選擇此選項時, org.springframework:spring-jdbc仍然是必需的依賴項。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM