首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >sql-maven-plugin:清理多个数据库?

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

Stack Overflow用户
提问于 2013-05-03 17:59:48
回答 1查看 1.8K关注 0票数 0

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

你们怎么解决这个问题?有没有解决这个问题的方法?

提前感谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-05-03 19:27:49

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

下面是一个连接到两个不同HSQLDB数据库的示例:

代码语言:javascript
复制
<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>
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16356278

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档