Install Liquibase with Maven

Last updated: July 14, 2025

Apache Maven is a software project management and comprehension tool, which is based on the concept of a project object model (POM). The Liquibase Maven integration lets you manage the build process and your database schema scripts from a central file called pom.xml.

Some Maven goals are only available with Liquibase Pro. The Maven Goals page lists all available Liquibase goals for use with Maven, with Pro-specific goals marked with a PRO label.

Before you begin

  • Install Maven. No action is needed if you already have Maven installed for your project. If you do not have Maven installed, refer to the official Maven installation page.

  • Ensure java is installed on your computer. You can check if Java is installed by running java -version in the CLI.

Procedure

1

Create a Liquibase Maven project directory to store all Liquibase files.

Tip: You can follow the Maven Standard Directory Layout by placing your Liquibase files, such as the changelog and liquibase.properties, in the src/main/resources folder. This matches the default classpath used by Maven and lets you reference files in your pom.xml with simple relative paths like changelog.sql, instead of needing full or custom paths.

2

In your Liquibase Maven project directory, create a pom.xml file.

If you are using Maven Standard Directory Layout, you can place this in the root directory of your project.

3

Add your plugin to the pom.xml file.

You can use the following example code.

Be sure to replace 4.33.0 with the version of Liquibase you'd like to use.

Example Code
<plugin>
  <groupId>org.liquibase</groupId>
  <artifactId>liquibase-maven-plugin</artifactId>
  <version>4.33.0</version>
</plugin>
4

Add Configurations.

Liquibase Maven goals require database connection details, changelog configuration, and other parameters. This example adds some basic configurations, but depending on your goal, you may need to add additional parameters. You can pass these values at runtime, but storing them in the pom.xml file or a separate liquibase.properties file is often easier and more maintainable. In the example code, we are adding configurations to the pom.xml file.

Note: If you choose to store your configurations in the liquibase.properties file, the properties file must reside in the src/main/resources directory or be specified in your search path. Liquibase properties must also be specified in the configuration section of the pom.xml file. These will follow the format <propertyFile>liquibase.properties</propertyFile>

Before using the example code, be sure to:

  • Set the version to the version of Liquibase Pro you would like to run

  • Replace your_changelog_file with a name and extension for your changelog file. We'll create one in the next steps. For now, choose a name and a file format. For example changelog.sql. Liquibase supports.xml, .yaml, and.json formats.

  • Replace your_db, your_hostname, your_port, and your_db_name to format your JDBC URL.

  • Replace your_username and your_password.

Example Code
<plugin>
  <groupId>com.liquibase</groupId>
  <artifactId>liquibase-maven-plugin</artifactId>
  <version>5.0.0</version>
  <configuration>
    <changeLogFile>your_changelog_file</changeLogFile>
    <url>jdbc:your_db//your_hostname:your_port/your_db_name</url>
    <username>dbuser</username>
    <password>dbpassword</password>
  </configuration>
</plugin>
5

Create a changelog file in the src/main/resources directory with the name of your_changelog_file, such as changelog.sql.

6

Add changesets to your changelog file.

Use the following examples depending on the format of the changelog you created:

<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
  xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
  xmlns:pro="http://www.liquibase.org/xml/ns/pro"
    xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
        http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd
        http://www.liquibase.org/xml/ns/dbchangelog-ext
        http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd
        http://www.liquibase.org/xml/ns/pro
        http://www.liquibase.org/xml/ns/pro/liquibase-pro-latest.xsd">
  <changeSet id="1" author="Liquibase">
    <createTable tableName="test_table">
      <column name="test_id" type="int">
        <constraints primaryKey="true"/>
      </column>
      <column name="test_column" type="varchar"/>
    </createTable>
  </changeSet>
</databaseChangeLog>

7

Run the update-sql goal to inspect the SQL before applying changes to your database

mvn liquibase:updateSQL
8

Deploy your changes by using the update goal.

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.

4c497d057f0f622a3abc67fdc533d5c32716148c

It is a best practice to store sensitive data in a Secrets Management tool with Liquibase Pro.