Liquibase 缺少 postgresql 缺少数据库驱动程序

Liquibase missing postgresql missing database driver

我们最近从 bash 的纯 PostgreSQL 开发过渡到 Liquibase 更新,我很难让应用程序达到 运行。

这是我的配置文件(liquibase.properties)

####     _     _             _ _
##      | |   (_)           (_) |
##      | |    _  __ _ _   _ _| |__   __ _ ___  ___
##      | |   | |/ _` | | | | | '_ \ / _` / __|/ _ \
##      | |___| | (_| | |_| | | |_) | (_| \__ \  __/
##      \_____/_|\__, |\__,_|_|_.__/ \__,_|___/\___|
##                  | |
##                  |_|
##
##      The liquibase.properties file stores properties which do not change often,
##      such as database connection information. Properties stored here save time
##      and reduce risk of mistyped command line arguments.
##      Learn more: https://www.liquibase.org/documentation/config_properties.html
####
####
##   Note about relative and absolute paths:
##      The liquibase.properties file requires paths for some properties.
##      The classpath is the path/to/resources (ex. src/main/resources).
##      The changeLogFile path is relative to the classpath.
##      The url H2 example below is relative to 'pwd' resource.
####
# Enter the path for your changelog file.
changeLogFile=db/changelog/master.xml

#### Enter the Target database 'url' information  ####
#liquibase.command.url=jdbc:h2:tcp://localhost:5432/foo
liquibase.command.url=jdbc:postgresql://localhost:5432/foo

# Enter the username for your Target database.
liquibase.command.username: my_username

# Enter the password for your Target database.
liquibase.command.password: my_password

每次我 运行 它,它总是抱怨缺少一些数据库驱动程序

$ liquibase update
####################################################
##   _     _             _ _                      ##
##  | |   (_)           (_) |                     ##
##  | |    _  __ _ _   _ _| |__   __ _ ___  ___   ##
##  | |   | |/ _` | | | | | '_ \ / _` / __|/ _ \  ##
##  | |___| | (_| | |_| | | |_) | (_| \__ \  __/  ##
##  \_____/_|\__, |\__,_|_|_.__/ \__,_|___/\___|  ##
##              | |                               ##
##              |_|                               ##
##                                                ## 
##  Get documentation at docs.liquibase.com       ##
##  Get certified courses at learn.liquibase.com  ## 
##  Free schema change activity reports at        ##
##      https://hub.liquibase.com                 ##
##                                                ##
####################################################
Starting Liquibase at 21:31:35 (version 4.4.2 #39 built at 2021-07-22 18:11+0000)
Liquibase Version: 4.4.2
Liquibase Community 4.4.2 by Datical
Unexpected error running Liquibase: java.lang.RuntimeException: Cannot find database driver: org.postgresql.Driver

For more information, please use the --log-level flag

这里是完整的调试日志

[2021-07-29 21:42:38] FINE [liquibase.configuration] No configuration value for liquibase.hub.apiKey found
[2021-07-29 21:42:38] FINE [liquibase.configuration] No configuration value for liquibase.filterLogMessages found
[2021-07-29 21:42:38] FINE [liquibase.resource] Adding path /home/leeoswald/Documents/foo-db/. to resourceAccessor liquibase.resource.FileSystemResourceAccessor
[2021-07-29 21:42:38] FINE [liquibase.configuration] No configuration value for liquibase.shouldRun aka should.run found
[2021-07-29 21:42:38] FINE [liquibase.configuration] Configuration liquibase.shouldRun is using the default value of true
####################################################
##   _     _             _ _                      ##
##  | |   (_)           (_) |                     ##
##  | |    _  __ _ _   _ _| |__   __ _ ___  ___   ##
##  | |   | |/ _` | | | | | '_ \ / _` / __|/ _ \  ##
##  | |___| | (_| | |_| | | |_) | (_| \__ \  __/  ##
##  \_____/_|\__, |\__,_|_|_.__/ \__,_|___/\___|  ##
##              | |                               ##
##              |_|                               ##
##                                                ## 
##  Get documentation at docs.liquibase.com       ##
##  Get certified courses at learn.liquibase.com  ## 
##  Free schema change activity reports at        ##
##      https://hub.liquibase.com                 ##
##                                                ##
####################################################
Starting Liquibase at 21:42:38 (version 4.4.2 #39 built at 2021-07-22 18:11+0000)
Liquibase Version: 4.4.2
Liquibase Community 4.4.2 by Datical
[2021-07-29 21:42:38] FINE [liquibase.configuration] No configuration value for liquibase.outputFile found
[2021-07-29 21:42:38] FINE [liquibase.configuration] No configuration value for liquibase.command.update.changeExecListenerClass found
[2021-07-29 21:42:38] FINE [liquibase.configuration] No configuration value for liquibase.command.changeExecListenerClass found
[2021-07-29 21:42:38] FINE [liquibase.configuration] No configuration value for liquibase.command.update.changeExecListenerPropertiesFile found
[2021-07-29 21:42:38] FINE [liquibase.configuration] No configuration value for liquibase.command.changeExecListenerPropertiesFile found
[2021-07-29 21:42:38] FINE [liquibase.configuration] No configuration value for liquibase.command.update.changelogFile found
[2021-07-29 21:42:38] FINE [liquibase.configuration] Found 'liquibase.command.changelogFile' configuration of 'db/changelog/master.xml'
    file /home/leeoswald/Documents/foo-db/liquibase.properties 'changeLogFile' of 'db/changelog/master.xml'
[2021-07-29 21:42:38] FINE [liquibase.configuration] No configuration value for liquibase.command.update.contexts found
[2021-07-29 21:42:38] FINE [liquibase.configuration] No configuration value for liquibase.command.contexts found
[2021-07-29 21:42:38] FINE [liquibase.configuration] No configuration value for liquibase.command.update.defaultCatalogName found
[2021-07-29 21:42:38] FINE [liquibase.configuration] No configuration value for liquibase.command.defaultCatalogName found
[2021-07-29 21:42:38] FINE [liquibase.configuration] No configuration value for liquibase.command.update.defaultSchemaName found
[2021-07-29 21:42:38] FINE [liquibase.configuration] No configuration value for liquibase.command.defaultSchemaName found
[2021-07-29 21:42:38] FINE [liquibase.configuration] No configuration value for liquibase.command.update.driver found
[2021-07-29 21:42:38] FINE [liquibase.configuration] No configuration value for liquibase.command.driver found
[2021-07-29 21:42:38] FINE [liquibase.configuration] No configuration value for liquibase.command.update.driverPropertiesFile found
[2021-07-29 21:42:38] FINE [liquibase.configuration] No configuration value for liquibase.command.driverPropertiesFile found
[2021-07-29 21:42:38] FINE [liquibase.configuration] No configuration value for liquibase.command.update.labels found
[2021-07-29 21:42:38] FINE [liquibase.configuration] No configuration value for liquibase.command.labels found
[2021-07-29 21:42:38] FINE [liquibase.configuration] No configuration value for liquibase.command.update.password found
[2021-07-29 21:42:38] FINE [liquibase.configuration] Found 'liquibase.command.password' configuration of '*****'
    file /home/leeoswald/Documents/foo-db/liquibase.properties 'liquibase.command.password' of '*****'
[2021-07-29 21:42:38] FINE [liquibase.configuration] No configuration value for liquibase.command.update.url found
[2021-07-29 21:42:38] FINE [liquibase.configuration] Found 'liquibase.command.url' configuration of 'jdbc:postgresql://localhost:5432/foo'
    file /home/leeoswald/Documents/foo-db/liquibase.properties 'liquibase.command.url' of 'jdbc:postgresql://localhost:5432/foo'
[2021-07-29 21:42:38] FINE [liquibase.configuration] No configuration value for liquibase.command.update.username found
[2021-07-29 21:42:38] FINE [liquibase.configuration] Found 'liquibase.command.username' configuration of 'postgres'
    file /home/leeoswald/Documents/foo-db/liquibase.properties 'liquibase.command.username' of 'postgres'
[2021-07-29 21:42:38] FINE [liquibase.command] Pipeline for command 'update: liquibase.command.core.UpdateCommandStep
[2021-07-29 21:42:38] FINE [liquibase.configuration] No configuration value for liquibase.propertyProviderClass found
[2021-07-29 21:42:38] FINE [liquibase.configuration] No configuration value for liquibase.databaseClass found
[2021-07-29 21:42:38] FINE [liquibase.configuration] No configuration value for liquibase.hub.url found
[2021-07-29 21:42:38] FINE [liquibase.configuration] Configuration liquibase.hub.url is using the default value of https://hub.liquibase.com
[2021-07-29 21:42:38] FINE [liquibase.integration] Liquibase Hub URL:      https://hub.liquibase.com
[2021-07-29 21:42:38] FINE [liquibase.configuration] No configuration value for liquibase.hub.mode found
[2021-07-29 21:42:38] FINE [liquibase.configuration] Configuration liquibase.hub.mode is using the default value of ALL
[2021-07-29 21:42:38] FINE [liquibase.integration] Liquibase Hub Mode:     ALL
[2021-07-29 21:42:38] FINE [liquibase.servicelocator] Loaded liquibase.database.Database instance liquibase.database.core.CockroachDatabase
[2021-07-29 21:42:38] FINE [liquibase.servicelocator] Loaded liquibase.database.Database instance liquibase.database.core.DB2Database
[2021-07-29 21:42:38] FINE [liquibase.servicelocator] Loaded liquibase.database.Database instance liquibase.database.core.Db2zDatabase
[2021-07-29 21:42:38] FINE [liquibase.servicelocator] Loaded liquibase.database.Database instance liquibase.database.core.DerbyDatabase
[2021-07-29 21:42:38] FINE [liquibase.servicelocator] Loaded liquibase.database.Database instance liquibase.database.core.Firebird3Database
[2021-07-29 21:42:38] FINE [liquibase.servicelocator] Loaded liquibase.database.Database instance liquibase.database.core.FirebirdDatabase
[2021-07-29 21:42:38] FINE [liquibase.servicelocator] Loaded liquibase.database.Database instance liquibase.database.core.H2Database
[2021-07-29 21:42:38] FINE [liquibase.servicelocator] Loaded liquibase.database.Database instance liquibase.database.core.HsqlDatabase
[2021-07-29 21:42:38] FINE [liquibase.servicelocator] Loaded liquibase.database.Database instance liquibase.database.core.InformixDatabase
[2021-07-29 21:42:38] FINE [liquibase.servicelocator] Loaded liquibase.database.Database instance liquibase.database.core.Ingres9Database
[2021-07-29 21:42:38] FINE [liquibase.servicelocator] Loaded liquibase.database.Database instance liquibase.database.core.MSSQLDatabase
[2021-07-29 21:42:38] FINE [liquibase.servicelocator] Loaded liquibase.database.Database instance liquibase.database.core.MariaDBDatabase
[2021-07-29 21:42:38] FINE [liquibase.servicelocator] Loaded liquibase.database.Database instance liquibase.database.core.MockDatabase
[2021-07-29 21:42:38] FINE [liquibase.servicelocator] Loaded liquibase.database.Database instance liquibase.database.core.MySQLDatabase
[2021-07-29 21:42:38] FINE [liquibase.servicelocator] Loaded liquibase.database.Database instance liquibase.database.core.OracleDatabase
[2021-07-29 21:42:38] FINE [liquibase.servicelocator] Loaded liquibase.database.Database instance liquibase.database.core.PostgresDatabase
[2021-07-29 21:42:38] FINE [liquibase.servicelocator] Loaded liquibase.database.Database instance liquibase.database.core.SQLiteDatabase
[2021-07-29 21:42:38] FINE [liquibase.servicelocator] Loaded liquibase.database.Database instance liquibase.database.core.SybaseASADatabase
[2021-07-29 21:42:38] FINE [liquibase.servicelocator] Loaded liquibase.database.Database instance liquibase.database.core.SybaseDatabase
[2021-07-29 21:42:38] FINE [liquibase.servicelocator] Loaded liquibase.database.Database instance liquibase.database.core.UnsupportedDatabase
[2021-07-29 21:42:38] FINE [liquibase.database] Properties:
[2021-07-29 21:42:38] FINE [liquibase.database] Key:'password' Value:'**********'
[2021-07-29 21:42:38] FINE [liquibase.database] Key:'user' Value:'postgres'
[2021-07-29 21:42:38] SEVERE [liquibase.integration] java.lang.RuntimeException: Cannot find database driver: org.postgresql.Driver
liquibase.exception.CommandExecutionException: liquibase.exception.LiquibaseException: Unexpected error running Liquibase: java.lang.RuntimeException: Cannot find database driver: org.postgresql.Driver
    at liquibase.command.CommandScope.execute(CommandScope.java:153)
    at liquibase.integration.commandline.CommandRunner.call(CommandRunner.java:45)
    at liquibase.integration.commandline.CommandRunner.call(CommandRunner.java:15)
    at picocli.CommandLine.executeUserObject(CommandLine.java:1953)
    at picocli.CommandLine.access00(CommandLine.java:145)
    at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2352)
    at picocli.CommandLine$RunLast.handle(CommandLine.java:2346)
    at picocli.CommandLine$RunLast.handle(CommandLine.java:2311)
    at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2179)
    at picocli.CommandLine.execute(CommandLine.java:2078)
    at liquibase.integration.commandline.LiquibaseCommandLine.lambda$execute(LiquibaseCommandLine.java:318)
    at liquibase.Scope.child(Scope.java:175)
    at liquibase.Scope.child(Scope.java:151)
    at liquibase.integration.commandline.LiquibaseCommandLine.execute(LiquibaseCommandLine.java:290)
    at liquibase.integration.commandline.LiquibaseCommandLine.main(LiquibaseCommandLine.java:83)
Caused by: liquibase.exception.LiquibaseException: Unexpected error running Liquibase: java.lang.RuntimeException: Cannot find database driver: org.postgresql.Driver
    at liquibase.integration.commandline.Main.run(Main.java:447)
    at liquibase.integration.commandline.Main.run(Main.java:225)
    at liquibase.Scope.child(Scope.java:175)
    at liquibase.Scope.child(Scope.java:151)
    at liquibase.integration.commandline.Main.run(Main.java:225)
    at liquibase.command.AbstractCliWrapperCommandStep.run(AbstractCliWrapperCommandStep.java:32)
    at liquibase.command.CommandScope.execute(CommandScope.java:147)
    ... 14 more
Caused by: liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: java.lang.RuntimeException: Cannot find database driver: org.postgresql.Driver
    at liquibase.integration.commandline.CommandLineUtils.createDatabaseObject(CommandLineUtils.java:125)
    at liquibase.integration.commandline.Main.doMigration(Main.java:1523)
    at liquibase.integration.commandline.Main.lambda$run[=12=](Main.java:402)
    at liquibase.Scope.lambda$child[=12=](Scope.java:166)
    at liquibase.Scope.child(Scope.java:175)
    at liquibase.Scope.child(Scope.java:165)
    at liquibase.Scope.child(Scope.java:144)
    at liquibase.integration.commandline.Main.run(Main.java:401)
    ... 20 more
Caused by: liquibase.exception.DatabaseException: java.lang.RuntimeException: Cannot find database driver: org.postgresql.Driver
    at liquibase.database.DatabaseFactory.openConnection(DatabaseFactory.java:217)
    at liquibase.database.DatabaseFactory.openConnection(DatabaseFactory.java:176)
    at liquibase.database.DatabaseFactory.openDatabase(DatabaseFactory.java:141)
    at liquibase.integration.commandline.CommandLineUtils.createDatabaseObject(CommandLineUtils.java:90)
    ... 27 more
Caused by: java.lang.RuntimeException: Cannot find database driver: org.postgresql.Driver
    at liquibase.database.DatabaseFactory.loadDriver(DatabaseFactory.java:272)
    at liquibase.database.DatabaseFactory.openConnection(DatabaseFactory.java:201)
    ... 30 more

Unexpected error running Liquibase: java.lang.RuntimeException: Cannot find database driver: org.postgresql.Driver

liquibase.exception.CommandExecutionException: liquibase.exception.LiquibaseException: Unexpected error running Liquibase: java.lang.RuntimeException: Cannot find database driver: org.postgresql.Driver
    at liquibase.command.CommandScope.execute(CommandScope.java:153)
    at liquibase.integration.commandline.CommandRunner.call(CommandRunner.java:45)
    at liquibase.integration.commandline.CommandRunner.call(CommandRunner.java:15)
    at picocli.CommandLine.executeUserObject(CommandLine.java:1953)
    at picocli.CommandLine.access00(CommandLine.java:145)
    at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2352)
    at picocli.CommandLine$RunLast.handle(CommandLine.java:2346)
    at picocli.CommandLine$RunLast.handle(CommandLine.java:2311)
    at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2179)
    at picocli.CommandLine.execute(CommandLine.java:2078)
    at liquibase.integration.commandline.LiquibaseCommandLine.lambda$execute(LiquibaseCommandLine.java:318)
    at liquibase.Scope.child(Scope.java:175)
    at liquibase.Scope.child(Scope.java:151)
    at liquibase.integration.commandline.LiquibaseCommandLine.execute(LiquibaseCommandLine.java:290)
    at liquibase.integration.commandline.LiquibaseCommandLine.main(LiquibaseCommandLine.java:83)
Caused by: liquibase.exception.LiquibaseException: Unexpected error running Liquibase: java.lang.RuntimeException: Cannot find database driver: org.postgresql.Driver
    at liquibase.integration.commandline.Main.run(Main.java:447)
    at liquibase.integration.commandline.Main.run(Main.java:225)
    at liquibase.Scope.child(Scope.java:175)
    at liquibase.Scope.child(Scope.java:151)
    at liquibase.integration.commandline.Main.run(Main.java:225)
    at liquibase.command.AbstractCliWrapperCommandStep.run(AbstractCliWrapperCommandStep.java:32)
    at liquibase.command.CommandScope.execute(CommandScope.java:147)
    ... 14 more
Caused by: liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: java.lang.RuntimeException: Cannot find database driver: org.postgresql.Driver
    at liquibase.integration.commandline.CommandLineUtils.createDatabaseObject(CommandLineUtils.java:125)
    at liquibase.integration.commandline.Main.doMigration(Main.java:1523)
    at liquibase.integration.commandline.Main.lambda$run[=12=](Main.java:402)
    at liquibase.Scope.lambda$child[=12=](Scope.java:166)
    at liquibase.Scope.child(Scope.java:175)
    at liquibase.Scope.child(Scope.java:165)
    at liquibase.Scope.child(Scope.java:144)
    at liquibase.integration.commandline.Main.run(Main.java:401)
    ... 20 more
Caused by: liquibase.exception.DatabaseException: java.lang.RuntimeException: Cannot find database driver: org.postgresql.Driver
    at liquibase.database.DatabaseFactory.openConnection(DatabaseFactory.java:217)
    at liquibase.database.DatabaseFactory.openConnection(DatabaseFactory.java:176)
    at liquibase.database.DatabaseFactory.openDatabase(DatabaseFactory.java:141)
    at liquibase.integration.commandline.CommandLineUtils.createDatabaseObject(CommandLineUtils.java:90)
    ... 27 more
Caused by: java.lang.RuntimeException: Cannot find database driver: org.postgresql.Driver
    at liquibase.database.DatabaseFactory.loadDriver(DatabaseFactory.java:272)
    at liquibase.database.DatabaseFactory.openConnection(DatabaseFactory.java:201)
    ... 30 more

谁能帮我解决这个问题?

您是否已经将 postgrest JDBC jar 复制到 liquidbase/lib 中? https://docs.liquibase.com/workflows/database-setup-tutorials/postgresql.html