隨筆-112  評論-73  文章-0  trackbacks-0

          以前一直是在pom.xml文件中調用ant 來執行dbunit,這樣有一個弊端就是ant 中的變量和pom中的變量不能很好的共享。

          今天發現一個m2 的插件,就是 DbUnit Maven Plugin 。這個插件的使用方法也很簡單,主頁上就有例子。

          <plugin>

          <groupId>org.codehaus.mojo</groupId>

          <artifactId>dbunit-maven-plugin</artifactId>

          <!--jar file that has the jdbc driver -->

          <dependencies>

          <!-- 是連接數據的jar包-->

          <dependency>

          <groupId>mysql</groupId>

          <artifactId>mysql-connector-java</artifactId>

          <version>5.1.6</version>

          </dependency>

          </dependencies>



          <!-- common configurations -->



          <!-- 連接數據庫的URL等信息-->

          <configuration>

          <driver>com.mysql.jdbc.Driver</driver>

          <url>jdbc:mysql://localhost:3306/xiangyun</url>

                              
          <username>xiangyun</username>

          <password>xiangyun</password>

          </configuration>

          <executions>

          <execution>



          <!-- 執行的階段 這個是在編譯測試文件時執行-->

          <phase>test-compile</phase>

          <goals>

          <goal>operation</goal>

          </goals>

          <configuration>

          <type>CLEAN_INSERT</type>



          <!-- 執行的文件的位置 同以前使用的dbunit 文件一樣-->

          <src>src/test/resources/initData.xml</src>

          </configuration>

          </execution>

          </executions>

          </plugin>
          這樣就會在執行編譯測試文件時執行DBunit的CLEAN_INSERT操作了。

          同時使用多個<src>filename</src>不好用,每個<execution>只能使用一個<src></src>,就是只能使用一個文件。
          posted on 2008-12-03 17:07 Libo 閱讀(1496) 評論(0)  編輯  收藏 所屬分類: maven

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 长顺县| 东辽县| 商水县| 合江县| 衢州市| 鄂尔多斯市| 南宁市| 闽侯县| 手机| 河池市| 聂拉木县| 临海市| 永康市| 龙江县| 金华市| 南昌市| 山东省| 佛教| 麟游县| 姚安县| 东莞市| 封丘县| 南召县| 九台市| 镇远县| 闵行区| 广安市| 藁城市| 无棣县| 同德县| 开平市| 海兴县| 进贤县| 邵阳市| 禄劝| 广丰县| 郴州市| 库车县| 洞口县| 沾益县| 乐都县|