我尝试了以下代码的许多不同变体(包括将数据库连接详细信息提取到标记中),但无论我做什么,表仍然是在错误的数据库中创建的。
我也尝试执行“使用 autofi”数据库,但这也不起作用,并且表仍然在不同的数据库中创建。
<plugin>
<!-- Used to automatically drop (if any) and create a database prior to running integration test cases. -->
<groupId>org.codehaus.mojo</groupId>
<artifactId>sql-maven-plugin</artifactId>
<version>1.5</version>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.0.5</version>
</dependency>
</dependencies>
<configuration> <!-- I'VE TRIED TAKING THIS OUT AS WELL -->
<!-- common configuration shared by all executions -->
<url>jdbc:mysql://localhost:3306/test</url>
<driver>com.mysql.jdbc.Driver</driver>
<username>root</username>
<password>root</password>
</configuration>
<executions>
<execution>
<!-- and finally run the schema creation script we just made with the hibernate3-maven-plugin -->
<id>create-schema</id>
<phase>process-test-resources</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<url>jdbc:mysql://localhost:3306/AUTOFI</url>
<driver>com.mysql.jdbc.Driver</driver>
<username>root</username>
<password>root</password>
<srcFiles>
<srcFile>src/test/resources/sql/schema.sql</srcFile>
</srcFiles>
<onError>continue</onError>
</configuration>
</execution>
<!-- drop db after test -->
<execution>
<id>drop-db-after-test</id>
<phase>test</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<url>jdbc:mysql://localhost:3306/test</url>
<driver>com.mysql.jdbc.Driver</driver>
<username>root</username>
<password>root</password>
<autocommit>true</autocommit>
<sqlCommand>drop database AUTOFI;</sqlCommand>
</configuration>
</execution>
</executions>
</plugin>
我使用了 maven-sql-plugin 示例作为模板,但这也不起作用。
我究竟做错了什么?
谢谢,肖恩