[英]How to create a SQL dump using sql-maven-plugin
I use the sql-maven-plugin to handle the database before and after the maven tests ran. 我使用sql-maven-plugin在maven测试运行之前和之后处理数据库。 The examples are pretty straight forward in regards to dropping/ creating schema, populating. 在删除/创建模式,填充方面,这些示例非常简单。
How can I create a SQL dump of the db using this plugin? 如何使用此插件创建数据库的SQL转储?
It looks like there is no way to do it with sql-maven-plugin
. 看起来没有办法用sql-maven-plugin
做到这一点。 The main purpose of that plugin is to execute SQL statements . 该插件的主要目的是执行SQL语句。 mysql-dump
is a separate tool for creating backups. mysql-dump
是一个用于创建备份的独立工具。 One of the possible solutions in this case is to use exec-maven-plugin 在这种情况下,可能的解决方案之一是使用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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.