mvn liquibase:generateChangeLog not working with an URL problem

1.4k Views Asked by At

I don't understand something with Liquibase and Spring Boot.

When I run my spring boot project with : mvn spring-boot:run

My changelog-v1.0.xml create a table and add two users inside my table user. So my liquibase is linked to my mySQL Database with success. But ... I don't know why, I can't used mvn liquibase command without failure.

Exemple, I want to save my database using :

mvn liquibase:generateChangeLog

But I have that log failure :

Failed to execute goal org.liquibase:liquibase-maven-plugin:4.9.0:generateChangeLog (default-cli) on project demo: The database URL has not been specified either as a parameter or in a properties file.

I think, when i'm using the command line, he don't use my configuration inside pox.xml but I don't know how to do that.

# pom.xml

         <plugin>
                <groupId>org.liquibase</groupId>
                <artifactId>liquibase-maven-plugin</artifactId>
                <version>4.9.0</version>
                <configuration>
                    <propertyFileWillOverride>true</propertyFileWillOverride>
                    <promptOnNonLocalDatabase>false</promptOnNonLocalDatabase>
                    <ChangeLogFile>src/main/resources/db/changelog/changelog-master.xml</ChangeLogFile>
                    <driver>${spring.datasource.driverClassName}</driver>
                    <url>${spring.datasource.url}</url>
                    <username>${spring.datasource.username}</username>
                    <password>${spring.datasource.password}</password>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>javax.xml.bind</groupId>
                        <artifactId>jaxb-api</artifactId>
                        <version>2.3.0</version>
                    </dependency>
                </dependencies>
            </plugin>

My pom.xml is correctly setup because new changelog file inside liquibase directory create or update my data from my mysql database.

1

There are 1 best solutions below

0
On

mvn liquibase:generateChangeLog does not depend on spring, so it is not going to read the spring file. You can either create a liquibase.properties file and reference it. I changed the pom to reference a properties file https://docs.liquibase.com/tools-integrations/maven/maven-pom-file.html and then changed the changeLogFile configuration to use outputChangeLogFile like this:

<outputChangeLogFile>src/main/resources/db/changelog/changelog-master.xml</outputChangeLogFile>