TangYuan使用教程-XML介绍

一个人想着一个人 提交于 2019-12-10 23:06:13

【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>>

#TangYuan之XML介绍


###1. Tangyuan中的XML文件

使用Tangyuan框架开发是通过配置和编写一系列的XML文来实现其功能,在开发过程中涉及的XML文件有如下四种:

描述 示例文件名 允许数量
框架主配置文件 tangyuan-configuration.xml 1
数据映射配置文件 tangyuan-mapper.xml 最多一个
分库分表配置文件 tangyuan-sharding.xml 最多一个
SQL服务文件 tangyuan-sqlservices.xml 多个

###2. tangyuan-configuration.xml schema设计

###3. tangyuan-configuration.xml配置示例

A. 数据源配置:

<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. 数据源组配置(可选,配置多个有规律的数据源,分库分表中使用):

<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. 默认事务使用配置(可选):

<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. 缓存定义配置(可选):

<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" />
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!