TangYuan使用教程-XML介紹

#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

schema設計圖

###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" />
相關文章
相關標籤/搜索