隨筆-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

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


          網站導航:
           
          主站蜘蛛池模板: 剑河县| 甘肃省| 北碚区| 榆林市| 合水县| 万州区| 行唐县| 汕头市| 尼木县| 涞水县| 广东省| 舟曲县| 漳州市| 合山市| 新疆| 西丰县| 高安市| 永登县| 南华县| 噶尔县| 普定县| 循化| 正安县| 罗甸县| 资兴市| 凤城市| 唐山市| 丹巴县| 肥西县| 喀什市| 嘉黎县| 绍兴市| 勐海县| 逊克县| 哈尔滨市| 乐山市| 沙湾县| 枞阳县| 宣恩县| 名山县| 大厂|