Logo

dev-resources.site

for different kinds of informations.

Adding Liquibase plugin into Apache Maven managed project

Published at
4/18/2024
Categories
java
maven
Author
saladlam
Categories
2 categories in total
java
open
maven
open
Author
8 person written this
saladlam
open
Adding Liquibase plugin into Apache Maven managed project

Setup

Content of database/liquibase.properties

driver: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/databasename
username: root
password: password
Enter fullscreen mode Exit fullscreen mode

Add the following into Maven's pom.xml file

<build>
    <plugins>
        <!-- other plugins ... -->
        <plugin>
            <groupId>org.liquibase</groupId>
            <artifactId>liquibase-maven-plugin</artifactId>
            <version>4.27.0</version>
            <configuration>
                <propertyFile>${project.basedir}/database/liquibase.properties</propertyFile>
                <!-- must use relative path because this will save into `databasechangelog` table
                rollback will fail if `FILENAME` not match -->
                <changeLogFile>database/changelog.xml</changeLogFile>
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>mysql</groupId>
                    <artifactId>mysql-connector-java</artifactId>
                    <version>8.0.33</version>
                </dependency>
            </dependencies>
        </plugin>
   </plugins>
</build>
<!-- other sections ... -->
Enter fullscreen mode Exit fullscreen mode

And put the database change file changelog.xml into database directory of project root.

Command

Apply all changes into the database

mvn liquibase:update
Enter fullscreen mode Exit fullscreen mode

Available commands can refer to here.

maven Article's
30 articles in total
Favicon
SpringBoot Web Service - Part 5 - Github Action
Favicon
SpringBoot Web Service - Part 2 - Preparing Using Spring Initializr
Favicon
SpringBoot Web Service - Part 1 - Create Repository
Favicon
SpringBoot Web Service - Part 4 - Initial Configuration
Favicon
Identifying and Removing Unused Dependencies in pom.xml
Favicon
JeKa: The Simplest Way to Start with Java for Real
Favicon
JeKa: The Simplest Way to Create Uber and Shade Jars
Favicon
JeKa: The Simplest Way to Publish on Maven Central
Favicon
Preparando o ambiente de desenvolvimento da melhor API de tabelas de campeonato que vocรช jรก viu!
Favicon
Maven Guide for Beginners
Favicon
Wednesday Links - Edition 2024-10-16
Favicon
Unlock 10% Discounts in 5 Minutes: Build a Drools Project with Maven
Favicon
Getting Started with Maven
Favicon
Quick fix: com.github.everit-org.json-schema:org.everit.json.schema:jar:1.12.2 was not found
Favicon
How to deploy to maven central repo
Favicon
No SNAPSHOTs
Favicon
Maven Commands Cheat Sheet
Favicon
Apache Maven Kirish
Favicon
Difference between mvn install and mvn package
Favicon
Adding Liquibase plugin into Apache Maven managed project
Favicon
Accelerate Maven Application Builds: Maximizing Efficiency with Docker Volumes for Maven Repository Sharing
Favicon
Check for newer versions of dependencies in pom.xml
Favicon
Accelerate Your Automation Testing with Maven: A Step-by-Step Guide ๐Ÿš€
Favicon
Junit Badge For Git Project
Favicon
Jenkins CICD
Favicon
Set JVM Timezone when running JUnit 5 tests
Favicon
Maven 4 - Part I - Easier Versions
Favicon
An Updated Guide to Maven Archetypes
Favicon
H2 database Setup Error Unable to load name org.hibernate.dialect.Oracle10gDialect
Favicon
Why I prefer Maven over Gradle

Featured ones: