隨筆-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 閱讀(1491) 評論(0)  編輯  收藏 所屬分類: maven

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


          網站導航:
           
          主站蜘蛛池模板: 剑阁县| 通辽市| 永州市| 长沙县| 荆门市| 泰兴市| 清流县| 平原县| 华容县| 苍梧县| 安龙县| 长垣县| 上杭县| 沙河市| 通河县| 墨竹工卡县| 玛曲县| 惠来县| 富裕县| 博白县| 瑞金市| 志丹县| 呼伦贝尔市| 河北省| 临颍县| 措勤县| 瑞金市| 元朗区| 鸡西市| 建阳市| 贵州省| 青海省| 阜康市| 手游| 视频| 灌南县| 东城区| 高清| 梁平县| 平塘县| 自贡市|