每次运行“mvn test”时,如何让maven运行以下插件。
我不希望每次运行时都发出“mvn sql:execute”
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sql-maven-plugin</artifactId>
<!-- JDBC Driver -->
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.0.5</version>
</dependency>
</dependencies>
<configuration>
<driver>com.mysql.jdbc.Driver</driver>
<url>jdbc:mysql://localhost:3306/jboss</url>
<username>xxx</username>
<password>xxxx</password>
<autocommit>true</autocommit>
<onError>continue</onError>
<srcFiles>
<srcFile>src/test/sql/removeuser.sql</srcFile>
</srcFiles>
</configuration>
</plugin>
答案 0 :(得分:1)
我完全为此创建了jcabi-mysql-maven-plugin
。它在pre-integration-test
阶段启动MySQL服务器并在post-integration-test
阶段将其关闭。
答案 1 :(得分:0)
您可以通过在插件标记内添加以下内容将目标(sql:execute)绑定到测试阶段:
<executions>
<execution>
<id>execute-sql</id>
<phase>test</phase>
<goals>
<goal>execute</goal>
</goals>
</execution>
</executions>