如何解决使用 r2dbc 配置进行 liquibase 初始化
尝试使用 r2dbc 和 init 数据库运行 spring boot。 我的 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.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 Boot reference documentation:
或者,您可以配置 Flyway 或 Liquibase 以在迁移期间为您配置数据源。这两个库都提供了用于设置要迁移的数据库的 url、用户名和密码的属性。
选择此选项时,org.springframework:spring-jdbc
仍然是必需的依赖项。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。