我们有一个使用maven配置的Java应用程序,该应用程序使用多个数据库。这是一个应用程序-许多架构。
我已经配置了flyway,已经过测试,并且效果很好,但是我的配置仅适用于一个数据库。
这是我的pom.xml使用一种模式进行测试:
4.0.0
com.test
test
0.0.1-SNAPSHOT
org.flywaydb
flyway-maven-plugin
3.0
jdbc:mysql://localhost:3306/argentina
test
test
mysql
mysql-connector-java
5.1.21
mysql
mysql-connector-java
5.1.21
更新:通过使用现在提供的答案,我将以下pom.xml配置为2个模式。
4.0.0
com.test
test
0.0.1-SNAPSHOT
org.flywaydb
flyway-maven-plugin
3.0
argentina
compile
migrate
jdbc:mysql://localhost:3306/argentina
test
test
filesystem:src/main/resources/db/migration
brazil
compile
migrate
jdbc:mysql://localhost:3306/brazil
test
test
filesystem:src/main/resources/test2/sql
mysql
mysql-connector-java
5.1.21
...
我执行飞行操作,但没有成功,这是我收到的错误:
[INFO] Copying 5 resources
[INFO] [compiler:compile {execution: default-compile}]
[INFO] Nothing to compile - all classes are up to date
[INFO] [flyway:migrate {execution: argentina}]
[INFO] Database: jdbc:mysql://localhost:3306/argentina (MySQL 5.5)
[INFO] Validated 4 migrations (execution time 00:00.006s)
[INFO] Current version of schema `argentina`: 45678
[INFO] Schema `argentina` is up to date. No migration necessary.
[INFO] [flyway:migrate {execution: brazil}]
[INFO] Database: jdbc:mysql://localhost:3306/brazil (MySQL 5.5)
[INFO] Validated 1 migration (execution time 00:00.003s)
[INFO] Current version of schema `brazil`: 1
[INFO] Schema `brazil` is up to date. No migration necessary.
[INFO] [flyway:migrate {execution: default-cli}]
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] org.flywaydb.core.api.FlywayException: DataSource not set! Check your configuration!
数据库配置正常。另外,我检查了架构是否还可以。
更新:我从命令行飞行通道中删除:它运行良好。谢谢Jk1