我想清理和填充两个不同的数据库,以便与Maven项目进行集成测试。我使用sql-maven-plugin,但是我不能让它处理不同的数据库(我只能有一个sql-maven-plugin的插件声明,configuration在它的executions之间是共享的)。
你们怎么解决这个问题?有没有解决这个问题的方法?
提前感谢!
发布于 2013-05-03 19:27:49
您可以简单地在每个单独的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>https://stackoverflow.com/questions/16356278
复制相似问题