ibatis 配置文件说明

本文详细解析了MyBatis配置文件的各个组成部分,包括属性设置、类型别名、数据源配置等内容,并介绍了如何通过配置文件实现高效的数据访问。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

 

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE sqlMapConfig
PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN"
"http://www.ibatis.com/dtd/sql-map-config-2.dtd">
<!-- Always ensure to use the correct XML header as above! 
总是确保使用正确的XML头上面!
-->
<sqlMapConfig>
<!-- The properties (name=value) in the file specified here can be used placeholders in this config file (e.g. “${driver}”. The file is relative to the classpath and is completely optional.
文件中的属性(name=value)可以使用占位符在这里指定的配置文件(例如“$ {driver} "。文件是相对于classpath和是完全可选的。
 -->
	<properties resource="examples/sqlmap/maps/SqlMapConfigExample.properties " />

<!-- These settings control SqlMapClient configuration details, primarily to do with transaction management. They are all optional (more detail later in this document).
这些设置控制SqlMapClient配置细节,主要与事务管理。他们都是可选的
 -->
	<settings
		cacheModelsEnabled="true"	enhancementEnabled="true"	lazyLoadingEnabled="true"	maxRequests="32"	maxSessions="10"	maxTransactions="5"	useStatementNamespaces="false"
	/>

<!-- Type aliases allow you to use a shorter name for long fully qualified class names. -->
	<typeAlias alias="order" type="testdomain.Order"/>

<!-- Configure a datasource to use with this SQL Map using SimpleDataSource. Notice the use of the properties from the above resource 
配置一个数据源使用这个SQL使用SimpleDataSource。注意从上面的资源属性的使用
-->
	<transactionManager type="JDBC" >
		<dataSource type="SIMPLE">
			<property name="JDBC.Driver" value="${driver}"/>
			<property name="JDBC.ConnectionURL" value="${url}"/>
			<property name="JDBC.Username" value="${username}"/>
			<property name="JDBC.Password" value="${password}"/>
			<property name="JDBC.DefaultAutoCommit" value="true" />
			<property name="Pool.MaximumActiveConnections" value="10"/>
			<property name="Pool.MaximumIdleConnections" value="5"/>
			<property name="Pool.MaximumCheckoutTime" value="120000"/>
			<property name="Pool.TimeToWait" value="500"/>
			<property name="Pool.PingQuery" value="select 1 from ACCOUNT"/>
			<property name="Pool.PingEnabled" value="false"/>
			<property name="Pool.PingConnectionsOlderThan" value="1"/>
			<property name="Pool.PingConnectionsNotUsedFor" value="1"/>
		</dataSource>
	</transactionManager>

<!-- Identify all SQL Map XML files to be loaded by this SQL map. Notice the paths are relative to the classpath. For now, we only have one… 
-->
	<sqlMap resource="examples/sqlmap/maps/Person.xml" />
</sqlMapConfig>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值