javamavenliquibase

Error: The database URL has not been specified either as a parameter or in a properties file when trying to perform a rollback


I am trying to perform a rollback but I am getting the following error

The database URL has not been specified either as a parameter or in a properties file.´

I do have the database URL in my pom file as you can see below ,so I don't think that's the problem

pom File

<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.4.3</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.petapilot</groupId>
    <artifactId>migrations</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>Migrations</name>
    <description>Demo project for Spring Boot</description>
    <properties>
        <java.version>15</java.version>
        <liquibase.mysql.url>jdbc:mysql://127.0.0.1:3306</liquibase.mysql.url>
        <liquibase.mysql.username>root</liquibase.mysql.username>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.liquibase</groupId>
            <artifactId>liquibase-core</artifactId>
            <version>4.3.1</version>
        </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-jdbc</artifactId>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

The database has a password . Do I have to write it too? How can I fix this?


Solution

  • I'm not sure about the way of configuring Liquibase through pom.xml file. I think you could try this way:

    
        <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>
    
    <configuration>
        <changeLogFile>changelog.xml</changeLogFile>
        <url>MyJDBCConnection</url>
        <username>dbuser</username>
        <password>dbpassword</password>
    </configuration>
    

    Yes, DB password is required for configuration

    Cheers!!