如何为两个DB配置Liquibase插件?

时间:2015-10-10 19:55:58

标签: java database maven database-migration liquibase

如何为Liquibase pluginMaven projectDB设置MySQL PostgreSQL

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

1 个答案:

答案 0 :(得分:0)

你可以多次声明插件,因为它链接到一个实现阶段,你也可以使用一个插件启动动态方式,多次插件迭代iterator-maven-plugin:

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

就我个人而言,我不建议使用这些解决方案,我代替您创建了两个配置文件并运行:

liquibase using maven with two databases does not work

想要在一次运行中使用两个不同的数据库,这违反了Java中责任分离的基本原则