在决定开题之前,我读了很多文章(在flyway和stackoverflow上)。大部分的解决方案都是围绕着3.0版本的flyway,如何设置你的pom来使用maven和flyway执行多个数据库。
我有一个需求,我必须使用不同的用户账户连接到多个模式,并使用flyway执行完全不同的SQL。
我试着按照以下步骤设置我的pom 文章但它无法识别多个执行标签和id。它抛出的错误信息是
[ERROR] Failed to execute goal org.flywaydb:flyway-maven-plugin:4.0.3:migrate (default-cli) on project Flyway_001: org.flywaydb.core.api.FlywayException: 无法连接到数据库。配置url、用户和密码!-> [帮助1]: org.flywaydb.core.api.FlywayException: Unable to connect to the database. -> [帮助1]
我的绒球看起来像
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.flyway</groupId>
<artifactId>Flyway_001</artifactId>
<version>1.0-SNAPSHOT</version>
<name>${project.artifactId}-${project.version}</name>
<properties>
<A.db.user>A_DB_USER</A.db.user>
<A.db.password>*******</A.db.password>
<A.db.schema>A_DB_SCHEMA</A.db.schema>
<A.db.url>jdbc:oracle:blah..blah</A.db.url>
<B.db.user>B_DB_USER</B.db.user>
<B.db.password>*******</B.db.password>
<B.db.schema>B_DB_SCHEMA</B.db.schema>
<B.db.url>jdbc:oracle:blah..blah</B.db.url>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-maven-plugin</artifactId>
<version>4.0.3</version>
<executions>
<execution>
<id>flyway-A</id>
<configuration>
<url>${A.db.url}</url>
<user>${A.db.user}</user>
<password>${A.db.password}</password>
<schemas>
<schema>${A.db.schema}</schema>
</schemas>
<table>T_HUB_SCHEMA_VERSION</table>
<baselineOnMigrate>false</baselineOnMigrate>
<locations>
<location>filesystem:src/main/resources/db/A</location>
</locations>
</configuration>
</execution>
<execution>
<id>flyway-B</id>
<configuration>
<url>${B.db.url}</url>
<user>${B.db.user}</user>
<password>${B.db.password}</password>
<schemas>
<schema>${B.db.schema}</schema>
</schemas>
<table>T_HUB_SCHEMA_VERSION</table>
<baselineOnMigrate>false</baselineOnMigrate>
<locations>
<location>filesystem:src/main/resources/db/B</location>
</locations>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
有人尝试过使用flyway 4.0连接到多个DB吗?如果有人能给我一些指导,说明我的方法有什么问题,我会很感激。
IDE抱怨执行元素下的标签。能够摆脱的抱怨,通过指定的是 目标 像这样的标签。
<execution>
<id>some-id</id>
<goals>
<goal>migrate</goal>
</goals>
</execution>