Liquibase changelog generation failing with Springboot and H2

Hi All,

I am trying to setup Liquibase in the already existing spring boot application. I am using embedded H2 database persisted in a file.

I am using liquibase maven pluging to generate the changelog file. Below is my section of pom.xml containing liquibase maven plugin details.

<plugin>
    <groupId>org.liquibase</groupId>
    <artifactId>liquibase-maven-plugin</artifactId>
    <version>3.4.1</version>
   <configuration>
        <changeLogFile>
           /src/main/resources/liquibase-outputChangeLog.xml
        </changeLogFile>
        <driver>org.h2.Driver</driver>
        <url>jdbc:h2:file:~/taskapp</url>
        <username>sa</username>
        <password>password</password>
     </configuration>               
</plugin> 

Liquibase dependency

<dependency>
    <groupId>org.liquibase</groupId>
     <artifactId>liquibase-core</artifactId>
      <version>3.4.1</version>
</dependency>

Now i am trying to generate the changelog file by firing the maven command

mvn liquibase:generateChangeLog

But i get the following error in the console

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

Best Regards,

Saurav

I found a similar question on StackOverflow: java - Error: The database URL has not been specified either as a parameter or in a properties file when trying to perform a rollback - Stack Overflow

It was answered by @rakhi with this:

  • instead of providing all database properties inside tag of pom.xml, create “liquibase.properties” and populate various properties relevant to liquibase(DB) in this file. For help with creating “liquibase.properties” file, visit this link
  • Try using configuration similar to below in your existing pom.xml file:
    <modelVersion>4.0.0</modelVersion>
        <groupId>com.my-group.app</groupId>
        <artifactId>Liqui<SampleDb>-app</artifactId>
        <version>1.0-SNAPSHOT</version>
        <build>
            <pluginManagement>
                <plugins>
                    <plugin>
                        <groupId>org.liquibase</groupId>
                        <artifactId>liquibase-maven-plugin</artifactId>
                        <version>3.9.0</version>
                        <configuration>
                            <propertyFile>liquibase.properties</propertyFile>
                        </configuration>
                        <dependencies>
                          <dependency>
                              <groupId><db_type></groupId>
                              <artifactId><db_type></artifactId>
                          </dependency>
                      </dependencies>
                    </plugin>
                </plugins>
            </pluginManagement>
        </build>
  • You could also try the following way by correcting your existing pom file. This link says to include liquibase attributes inside <configuration> section. May be try surrounding the liquibase attributes in your POM file in <configuration> section as below:
<configuration>
    <changeLogFile>changelog.xml</changeLogFile>
    <url>MyJDBCConnection</url>
    <username>dbuser</username>
    <password>dbpassword</password>
</configuration>

Yes, DB password is required for configuration