我有Java Sping Boot Gradle-Kotlin项目,其中我使用H2(DBMS)Jooq和Liquibase。我尝试运行“generateJooq”从Liquibase文件生成数据库架构,但我无法,因为我收到以下错误:
SLF4J: No SLF4J providers were found.
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See https://www.slf4j.org/codes.html#noProviders for further details.
SLF4J: Class path contains SLF4J bindings targeting slf4j-api versions 1.7.x or earlier.
SLF4J: Ignoring binding found at [jar:file:/C:/Users/Mykolas/.gradle/caches/modules-2/files-2.1/org.slf4j/slf4j-jdk14/1.7.30/d35953dd2fe54ebe39fdf18cfd82fe6eb35b25ed/slf4j-jdk14-1.7.30.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See https://www.slf4j.org/codes.html#ignoredBindings for an explanation.
Exception in thread "main" java.lang.NoClassDefFoundError: liquibase/resource/FileSystemResourceAccessor
at org.jooq.meta.extensions.liquibase.LiquibaseDatabase.export(LiquibaseDatabase.java:149)
at org.jooq.meta.extensions.AbstractInterpretingDatabase.connection(AbstractInterpretingDatabase.java:100)
at org.jooq.meta.extensions.AbstractInterpretingDatabase.create0(AbstractInterpretingDatabase.java:77)
at org.jooq.meta.AbstractDatabase.create(AbstractDatabase.java:342)
at org.jooq.meta.AbstractDatabase.create(AbstractDatabase.java:332)
at org.jooq.meta.AbstractDatabase.setConnection(AbstractDatabase.java:322)
at org.jooq.codegen.GenerationTool.run0(GenerationTool.java:546)
at org.jooq.codegen.GenerationTool.run(GenerationTool.java:239)
at org.jooq.codegen.GenerationTool.generate(GenerationTool.java:234)
at org.jooq.codegen.GenerationTool.main(GenerationTool.java:206)
Caused by: java.lang.ClassNotFoundException: liquibase.resource.FileSystemResourceAccessor
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
... 10 more
> Task :generateJooq FAILED
FAILURE: Build failed with an exception.
我的build.gradle.kts文件如下所示:
plugins {
java
id("org.springframework.boot") version "3.0.2"
id("io.spring.dependency-management") version "1.1.0"
id("nu.studer.jooq") version "8.0"
}
buildscript {
configurations["classpath"].resolutionStrategy.eachDependency {
if (requested.group == "org.jooq") {
useVersion("3.16.3")
}
}
dependencies {
classpath("org.yaml:snakeyaml:1.28")
classpath("org.jooq:jooq-meta-extensions-liquibase")
classpath("org.liquibase:liquibase-core")
classpath("org.slf4j:slf4j-jdk14:1.7.30")
}
}
group = "com.example"
version = "0.0.1-SNAPSHOT"
java.sourceCompatibility = JavaVersion.VERSION_17
repositories {
mavenCentral()
}
dependencies {
implementation("org.springframework.boot:spring-boot-starter-jooq")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.liquibase:liquibase-core")
runtimeOnly("com.h2database:h2")
testImplementation("org.springframework.boot:spring-boot-starter-test")
implementation("org.yaml:snakeyaml:1.28")
implementation("org.jooq:jooq-meta-extensions-liquibase")
implementation("org.slf4j:slf4j-jdk14:1.7.30")
jooqGenerator("org.yaml:snakeyaml:1.28")
jooqGenerator("org.jooq:jooq-meta-extensions-liquibase")
jooqGenerator("org.liquibase:liquibase-core")
jooqGenerator("org.slf4j:slf4j-jdk14:1.7.30")
}
tasks.withType<Test> {
useJUnitPlatform()
}
jooq {
version.set("3.16.3")
configurations {
create("main") {
generateSchemaSourceOnCompilation.set(true)
jooqConfiguration.apply {
logging = org.jooq.meta.jaxb.Logging.WARN
generator.apply {
name = "org.jooq.codegen.KotlinGenerator"
target.apply {
packageName = "com.example.main.db"
}
database.apply {
name = "org.jooq.meta.extensions.liquibase.LiquibaseDatabase"
properties.add(
org.jooq.meta.jaxb.Property().withKey("scripts")
.withValue("classpath:src/main/resources/db/changelog/migrations/db.changelog-V1.yaml")
)
properties.add(
org.jooq.meta.jaxb.Property().withKey("includeLiquibaseTables").withValue("false")
)
}
}
}
}
}
}
我已经按照我在网上找到的说明配置了这个文件,但它似乎仍然不起作用。我试过谷歌解决方案,但没有帮助。如果有人能帮我解决,我将不胜感激。
1条答案
按热度按时间b09cbbtk1#
Liquibase不兼容地更改了其API:https://github.com/liquibase/liquibase/issues/3478
这对使用Liquibase的第三方有影响,包括jOOQ的
LiquibaseDatabase
。jOOQ中解决的相关问题是:https://github.com/jOOQ/jOOQ/issues/14267上述修复将很快在jOOQ 3.18中发布(可能在2023年第一季度)。目前,请确保您使用的是jOOQ的
jooq-meta-extensions-liquibase
模块所依赖的Liquibase版本,至少用于代码生成目的。它可能会被Sping Boot 隐式升级,并且您没有指定任何显式版本: