Hi habr, a lot has already been written on the topic of liquibase and Maven, but I could not find anything about
liquibase-maven-plugin and its configuration, and yet this is a very convenient plugin. So I decided to write about how to configure it.
The liquibase-maven-plugin plugin is designed to manage Maven liquibase. Here is an example of the
mvn liquibase: update command to update the database.
To begin with, I propose to deal with what Maven and liquibase are.
')
Maven is a tool for building a Java project: compiling, creating a jar, creating a distribution package for a program, and generating documentation. More details about Maven itself can be found in the
Apache Maven article
- basics.
Liquibase is a database migration management system. To get familiar with liquiabase, you can also read the article
Managing DB Migrations with Liquibase
After we dealt with Maven and liquibase, you can proceed to creating a maven project and setting up a liquibase plugin.
To begin, create a new Maven project, its structure will look like this:
Accordingly, the pom file of this project will look like:
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>liquibaseTest</groupId> <artifactId>ru.test.liquibase</artifactId> <version>1.0-SNAPSHOT</version> </project>
Next in the folder “src / main / resources” we will create the folder “liquibase” in which we will store changelog files.
Create two files in the liquibase folder:
- db.changelog-master.xml - the main migration file, using the tag to
db.changelog-0.1.0.xml is a changjlog file containing changesets. Each changeset is one transaction.