Ant+dbunit Guide XML to MySQL

Source: Internet
Author: User

1. Add your own data directory and XML file

2.lib Dependency

    • 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 file as above

1<?XML version= "1.0" encoding= "UTF-8"?>23<ProjectName= "Project"Default=""Basedir=".">45<PropertyName= "Lib"Value= "Lib"/>6<PropertyName= "conf"Value= "conf"/>7<PropertyName= "Dbunit.operation.type"Value= "REFRESH"/>8<!--Clean_insert,refresh-910<PropertyEnvironment= "ENV"/>1112<!--Local environment-13<PropertyFile= "${conf}/application.properties"/>1415<!--Linux Environment-16<PropertyFile= "${env." Tx_conf_path}/application.properties "/>1718<PathId= "Lib.path">19<PathelementLocation= "${conf}"/>20<FilesetDir= "${lib}">21st<IncludeName= "**/*.jar"/>22</Fileset>23</Path>2425<!--Load init data-26<TargetName= "Load"Description= "Load test data into DB">27<EchoMessage= "Update the planned number of data in the database to ${env." Tx_conf_path} "/>28<TaskdefName= "Dbunit"ClassName= "Org.dbunit.ant.DbUnitTask"Classpathref= "Lib.path">29</Taskdef>30<!--REFRESH Clean_insert-31<DbunitDriver= "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 selectable way to delete, empty insert, append UPDATE, insert, REFRESH, delete, Delete_all, Clean_insert-33<OperationType= "${dbunit.operation.type}"Src= "Data/entity.xml"/>34<OperationType= "${dbunit.operation.type}"Src= "Data/entityconsume.xml"/>35<OperationType= "${dbunit.operation.type}"Src= "Data/entitylimit.xml"/>36<OperationType= "${dbunit.operation.type}"Src= "Data/effect.xml"/>37<OperationType= "${dbunit.operation.type}"Src= "Data/syspara.xml"/>38<OperationType= "${dbunit.operation.type}"Src= "Data/droppack.xml"/>39<OperationType= "${dbunit.operation.type}"Src= "Data/item.xml"/>40<OperationType= "${dbunit.operation.type}"Src= "Data/equip.xml"/>41 <operation type= "${dbunit.operation.type}"  Src= "Data/army.xml" /> 42 43 </dbunit>44 </< Span style= "color: #800000;" >target>45 </< Span style= "color: #800000;" >project>          

4. Running Results

buildfile:e:\heart\workspace\redalert_v0.1\build.xmlload: [echo] updates the planned number of data in the database to ${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:Seconds

Ant+dbunit Guide XML to MySQL

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.