0

我在 Kubuntu 上使用 snap 包管理器安装了 Liquibase CLI。

调用以下命令会导致

liquibase calculateChecksum 2022-01-06-test.sql::1::bobby.tables --changeLogFile 2022-01-06-test.sql 
--url jdbc:mysql://localhost:3306 --username root --password password 
--driver com.mysql.jdbc.Driver --classpath ~/.m2/repository/mysql/mysql-connector-java/8.0.21/mysql-connector-java-8.0.21.jar

导致堆栈跟踪(DEBUG)

liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: java.lang.RuntimeException: Cannot find database driver: com.mysql.jdbc.Driver
        at liquibase.integration.commandline.CommandLineUtils.createDatabaseObject(CommandLineUtils.java:131)
        at liquibase.integration.commandline.Main.doMigration(Main.java:1408)
        at liquibase.integration.commandline.Main$1.lambda$run$0(Main.java:361)
        at liquibase.Scope.lambda$child$0(Scope.java:160)
        at liquibase.Scope.child(Scope.java:169)
        at liquibase.Scope.child(Scope.java:159)
        at liquibase.Scope.child(Scope.java:138)
        at liquibase.Scope.child(Scope.java:222)
        at liquibase.Scope.child(Scope.java:226)
        at liquibase.integration.commandline.Main$1.run(Main.java:360)
        at liquibase.integration.commandline.Main$1.run(Main.java:193)
        at liquibase.Scope.child(Scope.java:169)
        at liquibase.Scope.child(Scope.java:145)
        at liquibase.integration.commandline.Main.run(Main.java:193)
        at liquibase.integration.commandline.Main.main(Main.java:156)
Caused by: liquibase.exception.DatabaseException: java.lang.RuntimeException: Cannot find database driver: com.mysql.jdbc.Driver
        at liquibase.database.DatabaseFactory.openConnection(DatabaseFactory.java:250)
        at liquibase.database.DatabaseFactory.openDatabase(DatabaseFactory.java:140)
        at liquibase.integration.commandline.CommandLineUtils.createDatabaseObject(CommandLineUtils.java:96)
        ... 14 more
Caused by: java.lang.RuntimeException: Cannot find database driver: com.mysql.jdbc.Driver
        at liquibase.database.DatabaseFactory.openConnection(DatabaseFactory.java:192)
        ... 16 more

我没有使用 liquibase.properties 文件,因为我只想计算一个 md5 哈希和,所以我可以将它与不同的 md5 值进行比较。

我需要将 mysql.jar 放在 liquibase 二进制文件所在的位置吗?

如果是这样,它作为快照包住在哪里?

4

1 回答 1

0

事实证明 Snap 不允许访问用户 $HOME 目录中的 .m2 文件夹(这是疯狂/愚蠢)。

因此,您需要授予 liquibase snap 对 .m2 文件夹的访问权限

要查看 Liquibase 可以访问的位置:

snap connections liquibase

这将打印出:

Interface        Plug                         Slot      Notes
home             liquibase:home               :home     -
network          liquibase:network            :network  -
personal-files   liquibase:dot-m2-repository  -         -
removable-media  liquibase:removable-media    -         -

然后运行以下命令以授予 Liquibase 对.m2文件夹的访问权限

sudo snap connect liquibase:dot-m2-repository

这应该允许 Liquibase 正常运行。

为什么这在任何地方都没有记录?我不知道...

于 2022-01-06T18:46:15.450 回答