0

I have a Spring Boot application that reads a property file defined in "D:\Project\conf_files".

@PropertySource(value = {"file:D:\\\\Project\\\\conf_files\\\\internal.properties"}, ignoreResourceNotFound = false)
public class MyApplication extends SpringBootServletInitializer {
    
    public static void main(String[] args) {
        SpringApplication.run(MyApplication .class, args);
    }
}

In the "internal.properties" file, I have defined Liquibase properties:

liquibase.database.driverClassName=com.mysql.jdbc.Driver
liquibase.database.url=jdbc:mysql://127.0.0.1:3306/customers
liquibase.database.user=root
liquibase.database.pwd=

I have also defined "liquibase.properties" as follows:

changeLogFile=src/main/resources/changelogs/db.changelog-master.xml
driver=${liquibase.database.driverClassName}
url=${liquibase.database.url}
username=${liquibase.database.user}
password=${liquibase.database.pwd}

The "liquibase-maven-plugin" in my project points to the Liquibase path as follows:

<plugin>
    <groupId>org.liquibase</groupId>
    <artifactId>liquibase-maven-plugin</artifactId>
    <version>${liquibase.version}</version>
        <configuration>
            <propertyFile>${basedir}/src/main/resources/liquibase.properties</propertyFile>-->
        </configuration>
    <executions>
        <execution>
            <id>liquibase-update</id>
            <phase>process-resources</phase>
            <goals>
                <goal>updateSQL</goal>
                <goal>update</goal>
            </goals>
        </execution>
    </executions>
</plugin>

However, I am encountering the following error:

[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:3.5.5:updateSQL (liquibase-update) on project chorniche-client-angular: Error setting up or running Liquibase: liquibase.exception.DatabaseException: java.lang.RuntimeException: Cannot find database driver: ${liquibase.database.driverClassName}

Am I missing something ??

Z4N4TI
  • 79
  • 1
  • 10
  • The error message suggests that Liquibase is not able to find the database driver class, which is specified as a property in the "liquibase.properties" file. One possible reason for this error is that the property placeholder "${liquibase.database.driverClassName}" is not being resolved properly. To verify this, you can try replacing the "${liquibase.database.driverClassName}" placeholder in the "liquibase.properties" file with the actual value of the driver class name "com.mysql.jdbc.Driver". – Guardian Apr 06 '23 at 10:20
  • If I place values statically within liquibase.properties, it works :d But I need to retrieve them from my configuration file – Z4N4TI Apr 06 '23 at 11:26
  • if you replace the driver class name and it works completely, it would be weird that liquibase can find url or username and password but reading driver className does not work. maybe there is a space after the driver name in internal file? – Guardian Apr 06 '23 at 12:02

0 Answers0