我有一个问题,我想使用kotlin-springboot-r2 dbc-liquibase
所以,当把我的build.gradle.kts像这样
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id("org.springframework.boot") version "3.0.6"
id("io.spring.dependency-management") version "1.1.0"
id("org.graalvm.buildtools.native") version "0.9.20"
id("org.jetbrains.kotlin.plugin.jpa") version "1.8.21"
kotlin("jvm") version "1.7.22"
kotlin("plugin.spring") version "1.7.22"
}
group = "com.abahafart.kotlin.template"
version = "0.0.1-SNAPSHOT"
java.sourceCompatibility = JavaVersion.VERSION_17
configurations {
compileOnly {
extendsFrom(configurations.annotationProcessor.get())
}
}
repositories {
mavenCentral()
}
dependencies {
implementation("org.springframework.boot:spring-boot-starter-data-jdbc")
// implementation("org.springframework.boot:spring-boot-starter-data-r2dbc")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation("org.liquibase:liquibase-core")
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
developmentOnly("org.springframework.boot:spring-boot-devtools")
runtimeOnly("mysql:mysql-connector-java:8.0.32")
// runtimeOnly("dev.miku:r2dbc-mysql:0.8.2.RELEASE")
testImplementation("org.springframework.boot:spring-boot-starter-test")
}
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "17"
}
}
tasks.withType<Test> {
useJUnitPlatform()
}
application.yml
spring:
datasource:
url: jdbc:mysql://localhost:3333/library?tlsVersion=TLSv1.2
username: mysql
password: mysqlpw
# r2dbc:
# url: r2dbc:mysql://localhost:3333/library?tlsVersion=TLSv1.2
# username: mysql
# password: mysqlpw
# pool:
# enabled: true
# initial-size: 1
# max-size: 20
它的作品,我expected,连接到数据库和liquibase工作
但是如果我想使用r2 dbc和liquibase,我的gradle和应用程序看起来像这样,liquibase不工作,但连接到数据库工作
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id("org.springframework.boot") version "3.0.6"
id("io.spring.dependency-management") version "1.1.0"
id("org.graalvm.buildtools.native") version "0.9.20"
id("org.jetbrains.kotlin.plugin.jpa") version "1.8.21"
kotlin("jvm") version "1.7.22"
kotlin("plugin.spring") version "1.7.22"
}
group = "com.abahafart.kotlin.template"
version = "0.0.1-SNAPSHOT"
java.sourceCompatibility = JavaVersion.VERSION_17
configurations {
compileOnly {
extendsFrom(configurations.annotationProcessor.get())
}
}
repositories {
mavenCentral()
}
dependencies {
// implementation("org.springframework.boot:spring-boot-starter-data-jdbc")
implementation("org.springframework.boot:spring-boot-starter-data-r2dbc")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation("org.liquibase:liquibase-core")
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
developmentOnly("org.springframework.boot:spring-boot-devtools")
runtimeOnly("mysql:mysql-connector-java:8.0.32")
runtimeOnly("dev.miku:r2dbc-mysql:0.8.2.RELEASE")
testImplementation("org.springframework.boot:spring-boot-starter-test")
}
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "17"
}
}
tasks.withType<Test> {
useJUnitPlatform()
}
spring:
# datasource:
# url: jdbc:mysql://localhost:3333/library?tlsVersion=TLSv1.2
# username: mysql
# password: mysqlpw
r2dbc:
url: r2dbc:mysql://localhost:3333/library?tlsVersion=TLSv1.2
username: mysql
password: mysqlpw
pool:
enabled: true
initial-size: 1
max-size: 20
我的问题是我需要什么样的依赖来液化工作?为什么liquibase可以和jdbc一起使用而不能和r2 dbc一起使用?
谢谢
1条答案
按热度按时间oug3syen1#
Liquibase基于JDBC而不是R2DBC,因此需要提供一个JDBC连接。
This answer to a similar question explains how to do that with Boot.