7

For some reason the Liquibase maven plugin is not using my property when I set it in my liquibase.properties file. When I run mvn liquibase:update I get the following INFO.

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

Due to this, the update fails as liquibase can't find the driver and can't connect to the database.

I saw this SO question but they are using the liquibase executable and not maven. I used it as an example on how to use the liquibase.properties file.

Setting up Liquibase with MS-SQL Server

I see where it is hitting an exception L571 to L588 the exception but the actual exception isn't printed out so I don't know the cause of the error.

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

Community
  • 1
  • 1
Kevin Vasko
  • 1,561
  • 3
  • 22
  • 45

3 Answers3

3

Rather than setting the classpath in a properties file, you must put the driver jar as a dependency in your maven POM.

See the documentation for the Liquibase Maven Task, and especially the section that describes different JDBC dependencies. Here's a snippet:

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>
SteveDonie
  • 8,700
  • 3
  • 43
  • 43
0

In my case it was a simple copy and paste issue.

The property driver in liquibase.properties ends with a space. after deleting the space everything was fine.

driver: com.mysql.cj.jdbc.Driver

vs

driver: com.mysql.cj.jdbc.Driver

Sma Ma
  • 3,343
  • 2
  • 31
  • 39
0

This answer put me in the right direction. In my case, it was that I needed to declare the Maven resource.

<build>
    <resources>
      <resource>
        <directory>src/main/resources</directory>
        <filtering>true</filtering>
      </resource>
    </resources>
</build>

Hope it helps!

gezanoletti
  • 147
  • 2
  • 14