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.xml
load:
[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: null
BUILD SUCCESSFUL
Total time: 25 seconds

ant+dbunit 导xml到mysql的更多相关文章

  1. Ant 之bulid.xml详解

    ANT build.xml文件详解(一) Ant的概念 可能有些读者并不连接什么是Ant以及入可使用它,但只要使用通过Linux系统得读者,应该知道 make这个命令.当编译Linux内核及一些软件的 ...

  2. Eclipse 自动生成 Ant的Build.xml 配置文件

    Eclipse 自动生成 Ant的Build.xml 配置文件,生成的方法很隐蔽 选择你要生成Build.xml文件的项目,右键. Export-> General -> Ant Buil ...

  3. Ant之build.xml详解

    Ant之build.xml详解 关键字: ant build.xml Ant的概念 可能有些读者并不连接什么是Ant以及入可使用它,但只要使用通过Linux系统得读者,应该知道make这个命令.当编译 ...

  4. 【转】Ant之build.xml详解

    关键字: ant build.xml Ant的概念 可能有些读者并不连接什么是Ant以及入可使用它,但只要使用通过Linux系统得读者,应该知道make这个命令.当编译Linux内核及一些软件的源程序 ...

  5. Ant运行build.xml执行服务器scp,异常解决jsch.jar

    公司ant打包上线 一直出现这个问题. Ant运行build.xml执行服务器scp,异常解决jsch.jar BUILD FAILEDD:\eclipse\eclipse-jee-luna-SR2- ...

  6. Ant之build.xml详解---可用

    Ant的概念 :在Eclipse中使用Ant Ant是Java平台下非常棒的批处理命令执行程序,能非常方便地自动完成编译,测试,打包,部署等等一系列任务,大大提高开发效率. Ant和make命令很像. ...

  7. 使用ant build build.xml报“includeantruntime was not set”警告及"Class not found: javac1.8"问题

    问题1:ant编译build.xml报“includeantruntime was not set”警告. 警告详情: warning: 'includeantruntime' was not set ...

  8. Ant:build.xml 结构

     Ant build.xml 结构 project target task data property datatype v\:* {behavior:url(#default#VML);} o\:* ...

  9. ANT编译build.xml

    一,体验ant就像每个语言都有HelloWorld一样,一个最简单的应用能让人感受一下Ant1,首先你要知道你要干什么,我现在想做的事情是:编写一些程序编译它们把它打包成jar包把他们放在应该放置的地 ...

随机推荐

  1. 关于硬盘和几种RAID

    1 硬盘的基本工作原理 1.1 硬盘部件结构图 1.2 主要参数术语解释 磁头:在与硬盘交换数据的过程 中,读操作远远快于写操作,硬盘厂商开发一种读/写分离磁头. 转速(Rotationl Speed ...

  2. HW6.26

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...

  3. HW6.23

    public class Solution { public static void main(String[] args) { boolean[] box = new boolean[101]; f ...

  4. leetcode@ [87] Scramble String (Dynamic Programming)

    Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrin ...

  5. rpi good tutorial

    http://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/quick-start/

  6. hdu 2716 Message Decowding

    Message Decowding Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others ...

  7. ExtJs4.1实现数据缓存

    Ext.onReady(function () {             Ext.define("ProvinceCity", {                 extend: ...

  8. Cocos2d-x 3.x学习笔记(一):开始Cocos2d之旅

    首先,进入官网下载cocos2d-x:http://www.cocos.com/download/,当然你需要注册一个账号才可以下载. 接下来需要跟着官网的配置文档配置一下开发环境,不得不说,Coco ...

  9. 二、JSP的3个编译指令,7个动作指令,9个内置对象

    JSP 3个编译指令 1)  page指令(基本不需要用到,使用默认即可) 主要属性: 1.Language:指定脚本所采用的语言类型,现在只支持java 2.Extends:定义当前jsp产生的se ...

  10. matlab color_rain colorbar

    来自http://www.aos.wisc.edu/~dvimont/matlab/Graphics_Tools/color_rain.html Listing of script color_rai ...