Using Liquibase Maven Plugin with Spring Boot

The Liquibase Maven Plugin using Spring Boot has two main features:

  • It collects all the .jar files in the classpath and builds a single uber-jar, which helps to execute your service in more convenient way.
  • It searches for the public static void main() method to flag any classes with such method signature as a runnable class.

As an option, you can run Liquibase in a Spring environment by declaring a liquibase.spring.SpringLiquibase bean:

<bean  id="liquibase"  class="liquibase.integration.spring.SpringLiquibase">
      <property  name="dataSource"  ref="myDataSource"  />
      <property  name="changeLog"  value="classpath:db-changelog.xml"  /> 

      contexts specifies the runtime contexts to use.
      <property  name="contexts"  value="test, production"  />


Running Maven Plugin with Spring Boot

  1. Create your Liquibase project directory to store all Liquibase files.
  2. Create a Liquibase properties file or use the existing file included with the Liquibase installation package.

Note: The examples directory provides XML, SQL, JSON, and YAML changelogs with the corresponding properties files.

  1. Add attributes that you want to store in the Liquibase properties file instead of run at the command prompt. Specify the database connection information and other attributes by following Specifying Properties in a Connection Profile. See also: Supported Databases and Adding and Updating Liquibase Drivers.
  1. Create a text file called pom.xml or use the pom.xml file created for your project. Specify your attributes based on the example:
<?xml version="1.0" encoding="UTF-8"?>
    <project  xmlns="" xmlns:xsi=""
        <relativePath/>  <!-- lookup parent from repository -->
    <description>Liquibase Project for Spring Boot</description>
  1. Create a text file called changelog.sql or use the changelog file from the examples directory. Liquibase also supports the .xml, .yaml, or .json changelog formats.
  1. Specify the changelog file in pom.xml or the Liquibase properties file, as follows:
  2. pom.xml: <changelog-file>your/path/to/changelog.sql</changelog-file>

    • Windows example: changelog-file: ..\path\to\changelog.sql
    • Linux example: changelog-file: ../path/to/changelog.sql

    If you use the Liquibase properties file, reference it from pom.xml, as follows: <propertyFile></propertyFile>.

  1. Add changesets to your changelog file. Use the following examples, depending on the format of the changelog you created.

  1. Download and unzip the file to your Liquibase directory. The file contains Java scripts to run a Spring application.

Note: In the src directory, you will see the path to application code: src/main/java/com/ and the path to unit tests: src/test/java/com/

  1. Run the following command to compile and test your Spring Boot application code:

  2. mvn compile package
  1. Run the update-sql goal to inspect the SQL before applying changes to your database:

  2. mvn liquibase:update-sql
  1. Deploy your changes by using the update goal:

  2. mvn liquibase:update

After your first update, you will see a new table along with the DATABASECHANGELOG table and DATABASECHANGELOGLOCK table added to the database.