示例数据导出方法说明
一、导出示例数据的步骤
- 在数据库中添加示例数据。
- 使用ExampleDataExport,示例数据导出工具,将数据库中数据导出为适合xml的文本数据,并打印到控制台。
- 注意:导出数据时,首先要保证src/test/resources/中config下的数据库配置正确。
二、示例数据导出工具(ExampleDataExport)具体使用方法:
1.填写表名
public class ExampleDataExport extends SpringTestSupport {
/**
* 导出一个或多个表的示例数据
* 首先要保证src/test/reources/中config下的数据库配置正确
*/
@Test
public void export() {
/** 如果是多个表,可以加在数组中 **/
String[] tables = {"es_shop"};
String xmlData = DBSolutionFactory.dbExport\(tables, true, "");
System.out.println(xmlData);
}
}
2.运行工具
工具继承了SpringTestSupport,所以Run As --> JUnit Test即可运行,运行后,控制台显示数据示例如下:
<action>
<command>insert</command>
<table>es_shop</table>
<fields>shop_id,shop_name,member_id,member_name,shop_disable,shop_createtime,shop_endtime</fields>
<values>1,'平台自营',2,'lifenlong','open',1421329391,0</values>
</action>
<action>
<command>insert</command>
<table>es_shop</table>
<fields>shop_id,shop_name,member_id,member_name,shop_disable,shop_createtime,shop_endtime</fields>
<values>5,'时尚女装/搭配',6,'demo_woman','open',1427854939,0</values>
</action>
<action>
<command>insert</command>
<table>es_shop</table>
<fields>shop_id,shop_name,member_id,member_name,shop_disable,shop_createtime,shop_endtime</fields>
<values>10,'母婴和玩具',11,'toys','open',1427962215,0</values>
</action>
<action>
<command>insert</command>
<table>es_shop</table>
<fields>shop_id,shop_name,member_id,member_name,shop_disable,shop_createtime,shop_endtime</fields>
<values>15,'食品酒水',16,'food','open',1428651347,0</values>
</action>
<action>
<command>insert</command>
<table>es_shop</table>
<fields>shop_id,shop_name,member_id,member_name,shop_disable,shop_createtime,shop_endtime</fields>
<values>16,'superman',25,'superman','open',1464430981,0</values>
</action>
<action>
<command>insert</command>
<table>es_shop</table>
<fields>shop_id,shop_name,member_id,member_name,shop_disable,shop_createtime,shop_endtime</fields>
<values>17,'化妆品店铺',26,'kans','open',1464509176,0</values>
</action>