gpt4 book ai didi

postgresql - liquibase 命令行错误 org.yaml.snakeyaml.Yaml

转载 作者:行者123 更新时间:2023-11-29 13:17:28 31 4
gpt4 key购买 nike

我正在执行以下操作:

liquibase --classpath=./postgresql-42.1.4.jar:./snakeyaml-1.12.jar --changeLogFile=./src/main/resources/db/changelog/db.changelog-master.yaml --username=postgres --password=mysecret --url=jdbc:postgresql://localhost:5432/mydatabase --driver=org.postgresql.Driver update

但是我得到一个错误

运行 Liquibase 时出现意外错误:org.yaml.snakeyaml.Yaml

并且没有其他引用资料说明我出现错误的原因。我怎么知道我使用的 snakeyml 库是否合适?

编辑:感谢@bilak,我添加了 --logLevel=debug 标志,但信息仍然不多

EBUG 10/31/17 4:24 PM: liquibase: Connected to postgres@jdbc:postgresql://localhost:5432/mysdatabase
DEBUG 10/31/17 4:24 PM: liquibase: Setting auto commit to false from true
DEBUG 10/31/17 4:24 PM: liquibase: Executing QUERY database command: select count(*) from public.databasechangeloglock
DEBUG 10/31/17 4:24 PM: liquibase: Executing QUERY database command: select count(*) from public.databasechangeloglock
DEBUG 10/31/17 4:24 PM: liquibase: Executing QUERY database command: SELECT LOCKED FROM public.databasechangeloglock WHERE ID=1
DEBUG 10/31/17 4:24 PM: liquibase: Lock Database
DEBUG 10/31/17 4:24 PM: liquibase: Executing UPDATE database command: UPDATE public.databasechangeloglock SET LOCKED = TRUE, LOCKEDBY = '172.17.0.1 (172.17.0.1)', LOCKGRANTED = '2017-10-31 16:24:07.734' WHERE ID = 1 AND LOCKED = FALSE
INFO 10/31/17 4:24 PM: liquibase: Successfully acquired change log lock
DEBUG 10/31/17 4:24 PM: liquibase: Release Database Lock
DEBUG 10/31/17 4:24 PM: liquibase: Executing UPDATE database command: UPDATE public.databasechangeloglock SET LOCKED = FALSE, LOCKEDBY = NULL, LOCKGRANTED = NULL WHERE ID = 1
INFO 10/31/17 4:24 PM: liquibase: Successfully released change log lock
Unexpected error running Liquibase: org.yaml.snakeyaml.Yaml

SEVERE 10/31/17 4:24 PM: liquibase: org.yaml.snakeyaml.Yaml
java.lang.NoClassDefFoundError: org/yaml/snakeyaml/Yaml
at liquibase.parser.core.yaml.YamlChangeLogParser.parse(YamlChangeLogParser.java:23)
at liquibase.Liquibase.getDatabaseChangeLog(Liquibase.java:229)
at liquibase.Liquibase.update(Liquibase.java:202)
at liquibase.Liquibase.update(Liquibase.java:192)
at liquibase.integration.commandline.Main.doMigration(Main.java:1126)
at liquibase.integration.commandline.Main.run(Main.java:184)
at liquibase.integration.commandline.Main.main(Main.java:103)
Caused by: java.lang.ClassNotFoundException: org.yaml.snakeyaml.Yaml
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 7 more

所以它连接起来了,而且这个错误肯定与错误的 org.yaml.snakeyaml.Yaml 有关,我猜 1.类路径没有帮助 2.我尝试使用的版本不合适

最佳答案

liquibase 的--classpath 命令行参数仅用于数据库驱动程序,通过它使snakeyaml 可用是行不通的。

传递给 java 的 -cp arg 确实有效,但需要注意的是,如果您还传递了 -jar,它将被忽略。

因此,您需要执行以下操作:

java -cp snakeyaml-1.12.jar:liquibase.jar:sqlite-jdbc-3.34.0.jar liquibase.integration.commandline.Main  --defaultsFile=liquibase.properties --changeLogFile=databaseChangelog.yaml --logLevel debug update

关于postgresql - liquibase 命令行错误 org.yaml.snakeyaml.Yaml,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46939527/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com