首页 文章

Liquibase maven插件没有使用classpath属性

提问于
浏览
2

出于某种原因,当我在 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无法找到驱动程序并且无法连接到数据库 .

我看到了这个问题,但是他们正在使用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

1 回答

  • 2

    您必须将驱动程序jar作为依赖项放在maven POM中,而不是在属性文件中设置类路径 .

    请参阅documentation for the Liquibase Maven Task,尤其是描述不同JDBC依赖关系的部分 . 这是一个片段:

    Maven Liquibase更新示例您需要确保在Maven POM文件的依赖项部分中包含数据库的相关JDBC驱动程序 . MySQL示例:

    <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>
    

相关问题