#TangYuan之XML介绍mysql
###1. Tangyuan中的XML文件sql
使用Tangyuan框架开发是经过配置和编写一系列的XML文来实现其功能,在开发过程当中涉及的XML文件有以下四种:缓存
描述 | 示例文件名 | 容许数量 |
---|---|---|
框架主配置文件 | tangyuan-configuration.xml | 1 |
数据映射配置文件 | tangyuan-mapper.xml | 最多一个 |
分库分表配置文件 | tangyuan-sharding.xml | 最多一个 |
SQL服务文件 | tangyuan-sqlservices.xml | 多个 |
###2. tangyuan-configuration.xml schema设计app
###3. tangyuan-configuration.xml配置示例框架
A. 数据源配置:ui
<dataSource id="ds" type="DBCP" isDefault="true"> <property name="username" value="root" /> <property name="password" value="123456" /> <property name="url" value="jdbc:mysql://127.0.0.1:3306/xxx?Unicode=true..." /> <property name="driver" value="com.mysql.jdbc.Driver" /> </dataSource>
B. 数据源组配置(可选,配置多个有规律的数据源,分库分表中使用):url
<dataSourceGroup groupId="dsGourp" type="DBCP" start="0" end="4"> <property name="username" value="root" /> <property name="password" value="123456" /> <property name="url" value="jdbc:mysql://127.0.0.1:3306/xxx{}?Unicode=true..." /> <property name="driver" value="com.mysql.jdbc.Driver" /> </dataSourceGroup>
C. 事务定义配置:设计
<transaction id="tx_01" behavior="required"/>
D. 默认事务使用配置(可选):code
<setDefaultTransaction type="method"> <property name="select*" value="tx_01"/> <property name="get*" value="tx_01"/> <property name="update*" value="tx_02"/> <property name="insert*" value="tx_02"/> <property name="delete*" value="tx_02"/> </setDefaultTransaction>
E. 缓存定义配置(可选):xml
<cache id="cache1" type="local" default="true"> <property name="strategy" value="FIFO"/> <property name="flushInterval" value="86400000"/> <property name="maxSize" value="1000"/> </cache>
F. 缓存组定义配置(可选):
<cacheGroup id="cacheGroup"> <cache ref="cache1" include="" exclude="" /> <cache ref="cache2" include="" exclude="" /> </cacheGroup>
G. 数据映射配置(可选):
<mapper resource="tangyuan-mapper.xml" />
H. 分库分表配置(可选):
<sharding resource="tangyuan-sharding.xml" />
I. SQL服务配置:
<plugin resource="tangyuan-sqlservices.xml" />