Tarun Gupta
Tarun Gupta

Reputation: 11

flywaydb: unable to instantiate jdbc driver

The JDBC drivers need to be in an non-classpath directory. I'm using Maven to setup the configuration for Flyway DB and migrate as a goal. I provided in jarDir configuration section the location of the JDBC drivers, but when I execute the migrate goal it still does not recognize the JDBC drivers concerned.

<plugin>
    <groupId>org.flywaydb</groupId>
    <artifactId>flyway-maven-plugin</artifactId>
    <version>3.0</version>
    <executions>
        <execution>
            <id>sql-enrichment-setup</id>
            <phase>pre-integration-test</phase>
            <goals>
                <goal>migrate</goal>
            </goals>
            <configuration>
                <url>jdbc:postgresql://localhost/enrichment?charSet=utf8</url>
                <user>enrichment</user>
                <password>enrichment</password>
                <schemas>
                    <schema>public</schema>
                </schemas>
                <table>schema_history</table>
                <initVersion>1.0</initVersion>
                <initDescription>Base Migration</initDescription>
                <jarDir>/Users/abc/jars</jarDir>
                <skip>${skipITs}</skip>
                <locations>
                    <location>
                        filesystem:${basedir}/integration-test-helpers/sql/enrichment/migrations
                    </location>
                </locations>
            </configuration>
        </execution>
    </executions>
</plugin>

But, when I execute I still get:

Failed to execute goal org.flywaydb:flyway-maven-plugin:3.0:migrate (sql-enrichment-setup) on project esa-core: org.flywaydb.core.api.FlywayException: Unable to instantiate jdbc driver: org.postgresql.Driver

How do I resolve this issue?

Upvotes: 1

Views: 3685

Answers (1)

Axel Fontaine
Axel Fontaine

Reputation: 35169

jarDir is not a configuration parameter for the Maven Plugin. It is only available in the command-line tool.

In your case you should add the JDBC driver as a dependency to the plugin. This way it won't show up on the application's classpath.

Upvotes: 0

Related Questions