java - Liquibase maven 插件未使用类路径属性

标签 java maven liquibase

由于某些原因,当我在 liquibase.properties 文件中设置 Liquibase maven 插件时,它没有使用我的属性。当我运行 mvn liquibase:update 时,我得到以下信息。

[INFO] there are no resolved artifacts for the Maven project.
[INFO] Parsing Liquibase Properties File
[INFO]   File: target/classes/liquibase.properties
[INFO]   'classpath' in properties file is not being used by this task.

因此,更新失败,因为 liquibase 找不到驱动程序,无法连接到数据库。

我看到了这个 SO 问题,但他们使用的是 liquibase 可执行文件而不是 maven。我将其用作有关如何使用 liquibase.properties 文件的示例。

Setting up Liquibase with MS-SQL Server

我看到它在哪里遇到异常 L571 到 L588 异常,但实际异常没有打印出来,所以我不知道错误的原因。

https://github.com/liquibase/liquibase/blob/9ae7f90a0bbbbcec229a0788afa74831db348ced/liquibase-maven-plugin/src/main/java/org/liquibase/maven/plugins/AbstractLiquibaseMojo.java#L573

最佳答案

与其在属性文件中设置类路径,不如将驱动程序 jar 作为依赖项放入 maven POM 中。

参见 documentation for the Liquibase Maven Task ,尤其是描述不同 JDBC 依赖项的部分。这是一个片段:

Example of Maven Liquibase Update

You need to ensure that you include the relevant JDBC driver for your database in the dependency section of Maven POM file.

MySQL example:

<project>
    <dependencies>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <!-- Replace with the version of the MySQL driver you want to use -->
            <version>${mysql-version}</version>
        </dependency>
    </dependencies>
</project>

关于java - Liquibase maven 插件未使用类路径属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43263866/

相关文章:

java - 如何简化这些 For 循环以节省代码行数?

java - 如何获取当前的maven目标版本

java - 使用 XmlPlexusConfiguration 为 bean 样式的 Maven 扩展导入更多配置

postgresql - Liquibase:PSQLException:使用 SQL 更改日志未终止美元

mysql - 使用 liquibase 对 SQL 文件中的注释进行转义

java - 将多个 TextView 保存为高分辨率图像

java - 我的使用数据库作为后端的 java 程序中不断重复细节

JavaScript 正则表达式到 Java 正则表达式 - 替换和 Lambda

jboss - Maven 错误 - 每次都下载依赖项

java - centos上liquibase安装,JNI报错