这篇文章描述了如何使用liquibase从maven更新两个数据库: liquibase使用maven和两个数据库 但是,当我在我的pom.xml(包含在下面)中尝试完全相同的配置时,它不起作用.运行'mvn liquibase:update'时出现此错误:
The driver has not been specified either as a parameter or in a properties file.
Run Code Online (Sandbox Code Playgroud)
运行verbose设置为true我得到:
[INFO] Settings----------------------------
[INFO] driver: null
[INFO] url: null
[INFO] username: null
[INFO] password: null
Run Code Online (Sandbox Code Playgroud)
所以看起来配置没有传递给liquibase.如果配置部分是外部执行它可以工作,但这会破坏多次执行的整个想法 - 你会想要为不同的执行使用不同的配置.
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-plugin</artifactId>
<version>1.9.5.0</version>
<executions>
<execution>
<phase>process-resources</phase>
<id>one</id>
<goals>
<goal>update</goal>
</goals>
<configuration>
<changeLogFile>src/main/resources/liquibase/changelog-master.xml</changeLogFile>
<driver>com.mysql.jdbc.Driver</driver>
<url>jdbc:mysql://127.0.0.1:3306/${database.development}</url>
<username>wifi_offload_app</username>
<password />
<dropFirst>${liquibase.dropFirst}</dropFirst>
</configuration>
</execution>
<execution>
<phase>process-resources</phase>
<id>two</id>
<goals>
<goal>update</goal>
</goals>
<configuration>
<changeLogFile>src/main/resources/liquibase/changelog-master-sbr.xml</changeLogFile>
<driver>com.mysql.jdbc.Driver</driver>
<url>jdbc:mysql://127.0.0.1:3307/${database.development.sbr}</url>
<username>wifi_offload_app</username>
<password />
<dropFirst>${liquibase.dropFirst}</dropFirst>
</configuration>
</execution>
</executions>
<dependencies> …Run Code Online (Sandbox Code Playgroud) 我的包结构如下:
在/db.changelog/db.changelod-master.xml中,我包含/db.changelog/v1/db.changelog-1.0.xml,其中,我还包括/db.changelog/v1/changeset软件包中的所有更改日志。
在我的应用程序中,我有两个配置文件:dev和prod,我需要根据Liquibase的“最佳实践”划分软件包的结构。有些变更日志可以在产品和开发环境中使用。
另外,我可以在changeset标记中使用context属性并显式设置dev或prod值,但是这种解决方法不是可取的。
简单用法如下:我切换到产品概要文件,并且将不会创建某些表,或者会跳过对数据库的某些插入。
您能帮我根据Liquibase“最佳实践”重构软件包的结构吗?