簡體   English   中英

我怎樣才能讓Maven在“ MVN測試”中運行MySQL插件

[英]How can I get maven to run mySQL plug at “mvn test”

每當我運行“ 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>

jcabi-mysql-maven-plugin這個目的創建了jcabi-mysql-maven-plugin 它開始MySQL服務器的pre-integration-test階段,並關閉它在post-integration-test階段。

您可以通過在plugin標簽內添加以下內容來將目標(sql:execute)綁定到測試階段:

            <executions>
                <execution>
                    <id>execute-sql</id>
                    <phase>test</phase>
                    <goals>
                        <goal>execute</goal>
                    </goals>
                </execution>
            </executions>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM