Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Liquibase maven plugin is not using classpath property

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

like image 201
Kevin Vasko Avatar asked Apr 06 '17 19:04

Kevin Vasko


People also ask

What does Liquibase Maven plugin do?

Liquibase is an open-source library for managing database schema changes; it's database independent, so it works with any supported database engine. Liquibase provides a Maven plugin to run database operations during the build process.

What is properties Maven plugin?

The Properties Maven Plugin is here to make life a little easier when dealing with properties. It provides goals to read properties from files and URLs and write properties to files, and also to set system properties. It's main use-case is loading properties from files or URLs instead of declaring them in pom.


1 Answers

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>
like image 190
SteveDonie Avatar answered Sep 19 '22 07:09

SteveDonie