简体   繁体   English

使用 r2dbc 配置进行 liquibase 初始化

[英]liquibase initialization with r2dbc config

Trying to run spring boot with r2dbc and init database.尝试使用 r2dbc 和 init 数据库运行 spring 引导。 My build.gradle looks like:我的 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 properties: 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

And after starting it falls with开始后它与

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

What do I do incorrectly?我做错了什么?

You need to add a dependency on org.springframework:spring-jdbc .您需要添加对org.springframework:spring-jdbc的依赖。 From the Spring Boot reference documentation :来自Spring 引导参考文档

Alternatively, you can configure either Flyway or Liquibase to configure a DataSource for you for the duration of the migration.或者,您可以配置 Flyway 或 Liquibase 以在迁移期间为您配置 DataSource。 Both these libraries offer properties to set the url, username and password of the database to migrate.这两个库都提供属性来设置 url、要迁移的数据库的用户名和密码。

When choosing this option, org.springframework:spring-jdbc is still a required dependency.选择此选项时, org.springframework:spring-jdbc仍然是必需的依赖项。

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

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