标签:
1.增加自己的data目录和xml数据文件
2.lib依赖
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&characterEncoding=UTF-8&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
标签:
原文地址:http://www.cnblogs.com/dagangzi/p/4861495.html