【问题标题】:flywaydb: unable to instantiate jdbc driverflywaydb:无法实例化 jdbc 驱动程序
【发布时间】:2015-03-23 22:16:16
【问题描述】:

JDBC 驱动程序需要位于非类路径目录中。我正在使用 Maven 来设置 Flyway DB 的配置,并将 migrate 作为目标。我在jarDir 配置部分提供了 JDBC 驱动程序的位置,但是当我执行migrate 目标时,它仍然无法识别相关的 JDBC 驱动程序。

<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>

但是,当我执行时,我仍然得到:

未能在项目 esa-core: org.flywaydb.core.api.FlywayException 上执行目标 org.flywaydb:flyway-maven-plugin:3.0:migrate (sql-enrichment-setup):无法实例化 jdbc 驱动程序:org .postgresql.Driver

我该如何解决这个问题?

【问题讨论】:

    标签: flyway


    【解决方案1】:

    jarDir 不是 Maven 插件的配置参数。它仅在命令行工具中可用。

    在您的情况下,您应该将 JDBC 驱动程序添加为插件的依赖项。这样它就不会出现在应用程序的类路径中。

    【讨论】:

      猜你喜欢
      • 2012-08-27
      • 2018-07-27
      • 2021-06-05
      • 1970-01-01
      • 2015-07-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-15
      相关资源
      最近更新 更多