繁体   English   中英

sql-maven-plugin:清理多个数据库?

[英]sql-maven-plugin: clean multiple databases?

我想清理并填充两个不同的数据库,以便与Maven项目进行集成测试。 我使用sql-maven-plugin ,但是无法使它处理不同的数据库( sql-maven-plugin只能有一个插件声明,并且configurationexecutions之间共享)。

你们如何解决呢? 有没有解决此问题的方法?

提前致谢!

您可以简单地在每个execution部分中定义所有configuration ,然后根据需要进行配置。 而不是共享配置。

因此,以下是连接到两个不同的HSQLDB数据库的示例:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>sql-maven-plugin</artifactId>
    <version>1.5</version>

    <dependencies>
      <dependency>
        <groupId>org.hsqldb</groupId>
        <artifactId>hsqldb</artifactId>
        <version>2.2.9</version>
      </dependency>
      <!-- you could add dependencies to other database drivers here -->
    </dependencies>

    <executions>
      <!-- execution against database 1 -->
      <execution>
        <id>database1</id>
        <phase>process-test-resources</phase>
        <goals>
          <goal>execute</goal>
        </goals>
        <!-- specific configuration for execution against database1 -->
        <configuration>
          <driver>org.hsqldb.jdbcDriver</driver>
          <url>jdbc:hsqldb:hsql://localhost:9999/database1</url>
          <username>sa</username>
          <password></password>
          <sqlCommand>select count(TYPE_NAME) from INFORMATION_SCHEMA.SYSTEM_TABLES</sqlCommand>
        </configuration>
      </execution>
      <!-- execution against database 2 -->
      <execution>
        <id>database2</id>
        <phase>process-test-resources</phase>
        <goals>
          <goal>execute</goal>
        </goals>
        <!-- specific configuration for execution against database2 -->
        <configuration>
          <driver>org.hsqldb.jdbcDriver</driver>
          <url>jdbc:hsqldb:hsql://localhost:8888/database2</url>
          <username>sa</username>
          <password></password>
          <sqlCommand>select count(TYPE_NAME) from INFORMATION_SCHEMA.SYSTEM_TABLES</sqlCommand>
        </configuration>
      </execution>
    </executions>
  </plugin>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM