[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:4.3.5:diff (default-cli) on project liquibase-demo:

Hi, I’m new in liquibase and I want to make a test project using spring boot, liquibase (4.3.5) and local database (Mysql 5.5.5) but I have some difficulties to configure it correctly for generating migration files…

I have this error when I do “mvn liquibase:diff”
Can you help me please :blush:?

  • pom.xml
<?xml version="1.0" encoding="UTF-8"?>


4.0.0

org.springframework.boot
spring-boot-starter-parent
2.5.2


com.liquibase
liquibase-demo
0.0.1-SNAPSHOT
liquibase-demo
Demo project for Spring Boot

<java.version>11</java.version>



org.springframework.boot
spring-boot-starter-actuator


org.springframework.boot
spring-boot-starter-web


org.liquibase
liquibase-core

    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
        <plugin>
            <groupId>org.liquibase</groupId>
            <artifactId>liquibase-maven-plugin</artifactId>
            <version>4.3.5</version>
            <configuration>
                <changeLogFile>src/main/resources/db/changelog/master.yml</changeLogFile>
                <diffChangeLogFile>src/main/resources/db/changelog/migration/${maven.build.timestamp}_changelog.xml</diffChangeLogFile>
                <driver>com.mysql.cj.jdbc.Driver</driver>
                <url>jdbc:mysql://127.0.0.1:3306/liquibase</url>
                <defaultSchemaName />
                <username>root</username>
                <password></password>
                <referenceUrl>hibernate:spring:com.iquibase.liquibasedemo.domain?dialect=org.hibernate.dialect.MySQL5Dialect</referenceUrl>
                <verbose>true</verbose>
                <logging>debug</logging>
            </configuration>
        </plugin>
    </plugins>
</build>
  • resources/application.properties
    spring.liquibase.enabled=true
    spring.application.name=liquibase demo
    spring.liquibase.change-log=classpath:db/changelog/master.yml
    spring.h2.console.enabled=true

  • resources/db/changelog/master.yml
    databaseChangeLog:
    - includeAll:
    path: db/changelog/migration

Hi @kandric

I think you missed adding the error here. I can’t see it in the post. Would you mind editing it and formatting if already provided or else adding the error log here?

Thanks,
Rakhi Agrawal

Hello, sorry I had totally forgotten it. Here is the error I get

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'liquibase' defined in class path resource [org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration$LiquibaseConfiguration.class]: Invocation of init method failed; nested exception is liquibase.exception.ChangeLogParseException: Error parsing classpath:db/changelog/master.yml








[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:4.3.5:diff (default-cli) on project liquibase-demo: 
[ERROR] Error setting up or running Liquibase:
[ERROR] liquibase.exception.DatabaseException: java.lang.RuntimeException: Driver class was not specified and could not be determined from the url (hibernate:spring:com.iquibase.liquibasedemo.domain?dialect=org.hibernate.dialect.MySQL8Dialect)
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.

Can you try moving the liquibase-hibernate5 dependency into the plugin dependencies something like below :

<plugin>
                <groupId>org.liquibase</groupId>
                <artifactId>liquibase-maven-plugin</artifactId>
                <version>${liquibase.version}</version>
                <dependencies>
                    <dependency>
                        <groupId>mysql</groupId>
                        <artifactId>mysql-connector-java</artifactId>
                        <version>5.1.26</version>
                        <type>jar</type>
                        <scope>compile</scope>
                    </dependency>
                    <dependency>
                        <groupId>org.liquibase.ext</groupId>
                        <artifactId>liquibase-hibernate5</artifactId>
                        <version>3.6-SNAPSHOT</version>
                    </dependency>
                </dependencies>
                <configuration>
                    <diffChangeLogFile>impl/diffchangelog.xml</diffChangeLogFile>
                    <changeLogFile>changelog.xml</changeLogFile>
.................

Please let us know the results.

Thanks!

1 Like