ant+dbunit 導xml到mysql

來源:互聯網
上載者:User

標籤:

1.增加自己的data目錄和xml資料檔案

2.lib依賴

  • commons-logging-1.1.1.jar
  • dbunit-2.4.8.jar
  • junit-4.9b2.jar
  • mysql-connector-java-3.1.12-bin.jar
  • slf4j-api-1.6.1.jar
  • slf4j-jcl-1.6.1.jar

3.ant檔案如上

 1 <?xml version="1.0"  encoding="UTF-8"?> 2  3 <project name="project" default="" basedir="."> 4  5     <property name="lib" value="lib" /> 6     <property name="conf" value="conf" /> 7     <property name="dbunit.operation.type" value="REFRESH" /> 8     <!--CLEAN_INSERT,REFRESH--> 9     10     <property environment="env" />11 12     <!--本地環境-->13     <property file="${conf}/application.properties" />14 15     <!--linux環境-->16     <property file="${env.TX_CONF_PATH}/application.properties" />17 18     <path id="lib.path">19       <pathelement location="${conf}"/>20         <fileset dir="${lib}">21             <include name="**/*.jar" />22         </fileset>23     </path>24 25     <!-- load init data -->26     <target name="load" description="load test data into db">27         <echo message="更新資料庫中的策劃配數資料 到 ${env.TX_CONF_PATH}" />28         <taskdef name="dbunit" classname="org.dbunit.ant.DbUnitTask" classpathref="lib.path">29         </taskdef>30         <!--REFRESH  CLEAN_INSERT-->31         <dbunit driver="com.mysql.jdbc.Driver" url="jdbc:mysql://${mysql.dbServer}?useUnicode=true&amp;characterEncoding=UTF-8&amp;rewriteBatchedStatements=true" userid="${mysql.user}" password="${mysql.passwd}" supportBatchStatement="true" >32             <!-- type可選擇的方式 刪除、清空插入、追加   UPDATE, INSERT, REFRESH, DELETE, DELETE_ALL, CLEAN_INSERT-->33             <operation type="${dbunit.operation.type}" src="data/Entity.xml" />34             <operation type="${dbunit.operation.type}" src="data/EntityConsume.xml" />35             <operation type="${dbunit.operation.type}" src="data/EntityLimit.xml" />36             <operation type="${dbunit.operation.type}" src="data/Effect.xml" />37             <operation type="${dbunit.operation.type}" src="data/SysPara.xml" />38             <operation type="${dbunit.operation.type}" src="data/DropPack.xml" />39             <operation type="${dbunit.operation.type}" src="data/Item.xml" />40             <operation type="${dbunit.operation.type}" src="data/Equip.xml" />41             <operation type="${dbunit.operation.type}" src="data/Army.xml" />42 43         </dbunit>44     </target>45 </project>

 

4. 運行結果

Buildfile: E:\heart\workspace\RedAlert_v0.1\build.xmlload:     [echo] 更新資料庫中的策劃配數資料 到 ${env.TX_CONF_PATH}   [dbunit] Executing operation: REFRESH   [dbunit]           on   file: E:\heart\workspace\RedAlert_v0.1\data\Entity.xml   [dbunit]           with format: null   [dbunit] Executing operation: REFRESH   [dbunit]           on   file: E:\heart\workspace\RedAlert_v0.1\data\EntityConsume.xml   [dbunit]           with format: null   [dbunit] Executing operation: REFRESH   [dbunit]           on   file: E:\heart\workspace\RedAlert_v0.1\data\EntityLimit.xml   [dbunit]           with format: null   [dbunit] Executing operation: REFRESH   [dbunit]           on   file: E:\heart\workspace\RedAlert_v0.1\data\Effect.xml   [dbunit]           with format: null   [dbunit] Executing operation: REFRESH   [dbunit]           on   file: E:\heart\workspace\RedAlert_v0.1\data\SysPara.xml   [dbunit]           with format: null   [dbunit] Executing operation: REFRESH   [dbunit]           on   file: E:\heart\workspace\RedAlert_v0.1\data\DropPack.xml   [dbunit]           with format: null   [dbunit] Executing operation: REFRESH   [dbunit]           on   file: E:\heart\workspace\RedAlert_v0.1\data\Item.xml   [dbunit]           with format: null   [dbunit] Executing operation: REFRESH   [dbunit]           on   file: E:\heart\workspace\RedAlert_v0.1\data\Equip.xml   [dbunit]           with format: null   [dbunit] Executing operation: REFRESH   [dbunit]           on   file: E:\heart\workspace\RedAlert_v0.1\data\Army.xml   [dbunit]           with format: nullBUILD SUCCESSFULTotal time: 25 seconds

 

ant+dbunit 導xml到mysql

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.