0

每次运行“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>
4

2 回答 2

1

jcabi-mysql-maven-plugin正是为此目的而创建的。它在阶段启动 MySQL 服务器并在pre-integration-test阶段关闭它post-integration-test

于 2013-10-09T17:09:09.197 回答
0

您可以通过在插件标签中添加以下内容将您的目标(sql:execute)绑定到测试阶段:

            <executions>
                <execution>
                    <id>execute-sql</id>
                    <phase>test</phase>
                    <goals>
                        <goal>execute</goal>
                    </goals>
                </execution>
            </executions>
于 2013-01-31T02:03:29.957 回答