在运行 maven 测试之前和之后,我使用sql-maven-plugin来处理数据库。这些示例在删除/创建模式、填充方面非常简单。
如何使用此插件创建数据库的 SQL 转储?
在运行 maven 测试之前和之后,我使用sql-maven-plugin来处理数据库。这些示例在删除/创建模式、填充方面非常简单。
如何使用此插件创建数据库的 SQL 转储?
看起来没有办法做到这一点sql-maven-plugin
。该插件的主要目的是执行 SQL 语句。mysql-dump
是用于创建备份的单独工具。在这种情况下,一种可能的解决方案是使用exec-maven-plugin
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<id>mysql-dump-create</id>
<phase>clean</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>${path_to_mysqldump}</executable>
<workingDirectory>${workdir}</workingDirectory>
<arguments>
<argument>--user=${user}</argument>
<argument>--password=${password}</argument>
<argument>--host=${host}</argument>
<argument>--result-file=${name}</argument>
<argument>${db}</argument>
</arguments>
</configuration>
</plugin>