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. Java 开发@ JDBC链接SQLServer2012

    下面请一字一句地看,一遍就设置成功,比你设置几十遍失败,费时会少得多. 首先,在连接数据库之前必须保证SQL Server 2012是采用SQL Server身份验证方式而不是windows身份验证方 ...

  2. 全栈式框架的选择:MEAN or MEANS?

    说明:个人博客地址为edwardesire.com,欢迎前来品尝.本博客作为备份和引流 这两个月一直在进行sails后端开发,其中遇到的问题不断.放在研究用户访问控制矸例程上的时间太多,最后也没用弄出 ...

  3. 局域网Internet的共享

    局域网接入Internet,之后,在服务器安装共享代理软件,可以使客户机通过代理软件接入Internet. 局域网接入Internet 而目前几乎所有的浏览器.下载软件.信件收发软件都支持代理服务器. ...

  4. JS实现复制到剪贴板

    <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...

  5. Spring MVC返回JSON数据

    将一个对象以json数据格式返回前台: @ResponseBody public  User login(User user) { return user; } 在控制器上使用@ResponseBod ...

  6. Struts2中DMI(动态方法调用)的错误问题(There is no Action mapped for namespace [/xxx] and action name [xxx!yyy] a)

    默认的Struts.xml中是这样的 <constant name="struts.enable.DynamicMethodInvocation" value="f ...

  7. PTA 5-14 电话聊天狂人 (25分)

    给定大量手机用户通话记录,找出其中通话次数最多的聊天狂人. 输入格式: 输入首先给出正整数NN(\le 10^5≤10​5​​),为通话记录条数.随后NN行,每行给出一条通话记录.简单起见,这里只列出 ...

  8. Unity3D之AssetBundle学习:Android上运行笔记

    路径统一 在Android上加载StreamingAssets文件夹下的AssetBundle文件,首先需要对加载地址进行处理,注意PC.Android和IOS的地址不一致需要针对不同的平台不同的处理 ...

  9. html中的body标签

    <head>标签代表的是页面的"头部",而<body>标签代表的就是页面的"身体"了.如果说<html>标签定义了网页的开始 ...

  10. Select-Object用法

    展开 modules 属性的详细信息 get-process |? {$_.processname -eq "cmd"}|select -ExpandProperty module ...