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. HDFS体系结构:(Distributed File System)

    分布式系统的大概图 服务器越来越多,客户端对服务器的管理就会越来越复杂,客户端如果是我们用户,就要去记住大量的ip. 对用户而言访问透明的就是分布式文件系统. 分布式文件系统最大的特点:数据存储在多台 ...

  2. [读书笔记]了不起的node.js(二)

    这周做项目做得比较散(应该说一直都是这样),总结就依据不同情境双开吧-这篇记录的是关于node的学习总结,而下一篇是做项目学到的web前端的知识. 1.HTTP篇 node的HTTP模块在第一篇时接触 ...

  3. Android问题-selection contains a component,button7,introduced in an ancestor and cannot be deleted.

    问题现象: 在开发Android时增加的控件想删除,可是删除时提示“Android问题-selection contains a component,button7,introduced in an ...

  4. ACCESS-类型转换函数

    类型转换涵数: 函数   返回类型   expression   参数范围   CBool     Boolean   任何有效的字符串或数值表达式.   CByte     Byte   0   至 ...

  5. [C++]VS2010功能设置

    VS2010快捷键设置 工具->选项->环境->键盘->[显示命令包含] 下面输入“对齐”关键字->窗口显示关于“对齐”的所有操作命令->选中“某一个”->[ ...

  6. A Tour of Go Images

    Package image defines the Image interface: package image type Image interface { ColorModel() color.M ...

  7. DTD - Attributes

    In a DTD, attributes are declared with an ATTLIST declaration. Declaring Attributes An attribute dec ...

  8. zzuoj 10409 10409: D.引水工程

    10409: D.引水工程 Time Limit: 2 Sec  Memory Limit: 128 MBSubmit: 96  Solved: 34[Submit][Status][Web Boar ...

  9. Mac OS环境下媒体文件分割工具mediafilesegmenter的简单使用(生成M3U8 TS文件)

    mediafilesegmenter是苹果开发的一款用于分割媒体文件的工具,其功能与mediastreamsegmenter相似,但操作更简单. * 具体可以对比博客中的另一篇简介<Mac OS ...

  10. MVC产生验证码

    来源地址: http://www.cnblogs.com/insus/p/3629269.html