无法使用命令行 运行 liquibase
Cant run liquibase with command line
我想使用 liquibase,但是当我想让它 运行 使用命令行时,会发生这种情况:
PS C:\Users\Ferid\Downloads\liquibase-3.6.0-bin> .\liquibase
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: ch/qos/logback/core/filter/Filter
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.privateGetMethodRecursive(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at sun.launcher.LauncherHelper.validateMainClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: ch.qos.logback.core.filter.Filter
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 7 more
我试过 liquibase-3.6.1,现在试过 liquibase-3.6.0
库文件夹中缺少一个必需的库。
请参阅下面的错误报告 link,其中另一位用户遇到了同样的问题。
It appears 3.6.1 is still missing slf4j-api-1.7.25 in the lib folder
and I still receive an error invoking liquibase via cli.
您有三个选择:
- 自己获取图书馆 [here]。
- 等待补丁
版本(也许自己提交修复)。
- 恢复到旧版本(3.5.5 应该可以)
您必须将此库添加到您的类路径中:
在我的例子中,我使用 Spring Boot liquibase 集成,所以,这是我的 build.gradle
liquibase 配置
buildscript {
dependencies {
classpath 'org.postgresql:postgresql:9.4.1211.jre7'
classpath 'org.liquibase:liquibase-core:3.6.3'
classpath "org.liquibase:liquibase-gradle-plugin:2.0.1"
}
}
plugins {
id 'org.springframework.boot' version '2.1.3.RELEASE'
id 'java'
id "org.liquibase.gradle" version "2.0.1"
}
dependencies {
liquibaseRuntime 'org.postgresql:postgresql:9.4.1211.jre7'
liquibaseRuntime 'org.liquibase:liquibase-core:3.6.3'
liquibaseRuntime 'org.liquibase:liquibase-groovy-dsl:2.0.1'
liquibaseRuntime 'ch.qos.logback:logback-core:1.2.3'
liquibaseRuntime 'ch.qos.logback:logback-classic:1.2.3'
}
def changeLog = "$projectDir/src/main/db/changelog.xml"
liquibase {
activities {
main {
changeLogFile changeLog
url 'jdbc:postgresql://localhost:5431/postgres'
username 'postgres'
password 'postgres'
}
}
}
我在版本 3.6.2
中偶然发现了同样的问题。问题是 Liquibase 找不到所需的 类(ch.qos.logback.core.filter.Filter
只是其中之一,但还有其他)。没有通用的方法,但高级想法是找到所需 类 所在的 JAR,并将它们提供给 -cp
命令行参数。看起来有点难看,但这是最终起作用的:
#!/bin/bash
M2_REPO=/home/raiks/.m2/repository
LIQUIBASE_CMDLINE='liquibase.integration.commandline.Main --changeLogFile=~/changelog-master.xml update'
# Feed all the required JARs to -cp
JAVA_CMD="java -cp $M2_REPO/org/liquibase/liquibase-core/3.6.2/liquibase-core-3.6.2.jar:$M2_REPO/org/slf4j/slf4j-api/1.7.5/slf4j-api-1.7.5.jar:$M2_REPO/ch/qos/logback/logback-core/1.2.3/logback-core-1.2.3.jar:$M2_REPO/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar $LIQUIBASE_CMDLINE"
echo $JAVA_CMD
eval $JAVA_CMD
请注意,我在 Linux 上使用 :
,而在 Windows 上需要 ;
。根据您的具体 JAR 位置调整命令。
或者,您可以将依赖项放入目录并在 -cp
:
之后使用通配符指定它
$ java -cp "/home/raiks/liquibase-deps/*" liquibase.integration.commandline.Main --changeLogFile=~/changelog-master.xml update
我想使用 liquibase,但是当我想让它 运行 使用命令行时,会发生这种情况:
PS C:\Users\Ferid\Downloads\liquibase-3.6.0-bin> .\liquibase
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: ch/qos/logback/core/filter/Filter
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.privateGetMethodRecursive(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at sun.launcher.LauncherHelper.validateMainClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: ch.qos.logback.core.filter.Filter
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 7 more
我试过 liquibase-3.6.1,现在试过 liquibase-3.6.0
库文件夹中缺少一个必需的库。
请参阅下面的错误报告 link,其中另一位用户遇到了同样的问题。
It appears 3.6.1 is still missing slf4j-api-1.7.25 in the lib folder and I still receive an error invoking liquibase via cli.
您有三个选择:
- 自己获取图书馆 [here]。
- 等待补丁 版本(也许自己提交修复)。
- 恢复到旧版本(3.5.5 应该可以)
您必须将此库添加到您的类路径中:
在我的例子中,我使用 Spring Boot liquibase 集成,所以,这是我的 build.gradle
liquibase 配置
buildscript {
dependencies {
classpath 'org.postgresql:postgresql:9.4.1211.jre7'
classpath 'org.liquibase:liquibase-core:3.6.3'
classpath "org.liquibase:liquibase-gradle-plugin:2.0.1"
}
}
plugins {
id 'org.springframework.boot' version '2.1.3.RELEASE'
id 'java'
id "org.liquibase.gradle" version "2.0.1"
}
dependencies {
liquibaseRuntime 'org.postgresql:postgresql:9.4.1211.jre7'
liquibaseRuntime 'org.liquibase:liquibase-core:3.6.3'
liquibaseRuntime 'org.liquibase:liquibase-groovy-dsl:2.0.1'
liquibaseRuntime 'ch.qos.logback:logback-core:1.2.3'
liquibaseRuntime 'ch.qos.logback:logback-classic:1.2.3'
}
def changeLog = "$projectDir/src/main/db/changelog.xml"
liquibase {
activities {
main {
changeLogFile changeLog
url 'jdbc:postgresql://localhost:5431/postgres'
username 'postgres'
password 'postgres'
}
}
}
我在版本 3.6.2
中偶然发现了同样的问题。问题是 Liquibase 找不到所需的 类(ch.qos.logback.core.filter.Filter
只是其中之一,但还有其他)。没有通用的方法,但高级想法是找到所需 类 所在的 JAR,并将它们提供给 -cp
命令行参数。看起来有点难看,但这是最终起作用的:
#!/bin/bash
M2_REPO=/home/raiks/.m2/repository
LIQUIBASE_CMDLINE='liquibase.integration.commandline.Main --changeLogFile=~/changelog-master.xml update'
# Feed all the required JARs to -cp
JAVA_CMD="java -cp $M2_REPO/org/liquibase/liquibase-core/3.6.2/liquibase-core-3.6.2.jar:$M2_REPO/org/slf4j/slf4j-api/1.7.5/slf4j-api-1.7.5.jar:$M2_REPO/ch/qos/logback/logback-core/1.2.3/logback-core-1.2.3.jar:$M2_REPO/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar $LIQUIBASE_CMDLINE"
echo $JAVA_CMD
eval $JAVA_CMD
请注意,我在 Linux 上使用 :
,而在 Windows 上需要 ;
。根据您的具体 JAR 位置调整命令。
或者,您可以将依赖项放入目录并在 -cp
:
$ java -cp "/home/raiks/liquibase-deps/*" liquibase.integration.commandline.Main --changeLogFile=~/changelog-master.xml update