由于某些原因,当我在 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 异常,但实际异常没有打印出来,所以我不知道错误的原因。
最佳答案
与其在属性文件中设置类路径,不如将驱动程序 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/