【问题标题】:How to configure Liquibase plugin for two DB?如何为两个数据库配置 Liquibase 插件?
【发布时间】:2016-01-08 14:07:24
【问题描述】:

两个DBMySQLPostgreSQL)如何配置Liquibase pluginMaven project

我只配置了liquibase MySQL DB。还需要PostgreSQL DB

PostgreSQL DB 的属性:

driverClassName = org.postgresql.Driver
url = jdbc:postgresql://localhost:5432/postgresql_db
username = postgres
password = root
  • pom.xml:

    <build><plugins>
        <plugin>
            <groupId>org.liquibase</groupId>
            <artifactId>liquibase-maven-plugin</artifactId>
            <version>3.4.1</version>
            <configuration>
                <changeLogFile>src/main/resources/dbliquibase/dbchangelog.xml</changeLogFile>
                <driver>com.mysql.jdbc.Driver</driver>
                <url>jdbc:mysql://localhost:3306/mysql_db</url>
                <username>root</username>
                <password>root</password>
                <promptOnNonLocalDatabase>false</promptOnNonLocalDatabase>
            </configuration>
        </plugin>
    </plugins></build>
    

【问题讨论】:

  • 您是否尝试过定义 2 个executions 并为每个数据库配置一个?

标签: java database maven database-migration liquibase


【解决方案1】:

您可以声明的插件与实现阶段链接的次数一样多,您还可以使用启动动态方式的插件和多次插件迭代 iterator-maven-plugin :

http://khmarbaise.github.io/iterator-maven-plugin/

我个人不推荐这些解决方案,我代替你创建了两个配置文件,然后运行其中一个:

liquibase using maven with two databases does not work

想同时运行两个不同的数据库有悖于Java中职责分离的基本原则

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-10-16
    • 2019-08-30
    • 2014-07-07
    • 2022-06-16
    • 1970-01-01
    • 2017-09-16
    • 1970-01-01
    相关资源
    最近更新 更多