Spring配置iBatis多个SqlMapConfig.xml
来源:互联网 发布:彩虹秒赞源码7.8 编辑:程序博客网 时间:2024/05/21 23:33
Spring粘合iBatis的时候需要配置iBatis的SqlMapConfig.xml
对于项目多个模块而又想同时能管理起来,普遍的单个SqlMapConfig.xml就会显得臃肿
可喜的是Spring已经为大家想好这一切,提供能灵活的配置
configLocation // 单个SqlMapConfig.xml
configLocations // 多个SqlMapConfig.xml
mappingLocations // 自动匹配SqlMapConfig.xml
假设现在有几个配置文件,分别存放在不同的目录,结构如下
classes
|----SqlMapConfig.xml
|----com.xxx
|----aModule
| |----A-SqlMapConfig.xml
|----BModule
|----B-SqlMapConfig.xml
现在通过Spring配置以上几个SqlMapConfig.xml
- <bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
- <!-- 1. 配置单个SqlMapConfig.xml, 使用configLocation属性-->
- <property name="configLocation" value="classpath:SqlMapConfig.xml"/>
- <!-- 2. 配置多个SqlMapConfig.xml, 使用configLocations属性-->
- <!-- 不包含class目录下的SqlMapConfig.xml -->
- <property name="configLocations">
- <list>
- <value>classpath:com/xxx/a/A-SqlMapConfig.xml</value>
- <value>classpath:com/xxx/b/B-SqlMapConfig.xml</value>
- </list>
- </properties>
- <!-- 3. 匹配多个SqlMapConfig.xml, 使用mappingLocation属性-->
- <!-- 不包含class目录下的SqlMapConfig.xml -->
- <property name="mappingLocation" value="classpath:com/xxx/*/*-SqlMapConfig.xml"/>
- <!-- 其他配置,例如dataSource等等 -->
- <property name="dataSource" ref="dataSource"/>
- </bean>
这样,Spring就解决了多个模块下不同模块之前独立配置sqlMapConfog.xml的问题了。这个Spring2.5.5以后才支持
iBatis也能解决这类问题,不过要是iBatis高版本才支持,因为我使用的是2.3的,这方面就没有验证了
- <?xml version="1.0" encoding="UTF-8"?>
- <sqlMapConfig>
- <!-- <sqlMapImport resource="" url=""/> -->
- <sqlMapImport resource="com/xxx/a/A-SqlMapConfig.xml"/>
- <sqlMapImport resource="com/xxx/b/B-SqlMapConfig.xml"/>
- </sqlMapConfig>
- Spring配置iBatis多个SqlMapConfig.xml
- Spring配置iBatis多个SqlMapConfig.xml
- Spring配置iBatis多个SqlMapConfig.xml
- Spring配置iBatis多个SqlMapConfig.xml
- ibatis SqlMapConfig.xml 配置
- ibatis - sqlMapConfig.xml配置
- iBatis的SqlMapConfig.xml配置
- ibatis SqlMapConfig.xml 配置settings
- ibatis SqlMapConfig.xml 配置settings
- ibatis SqlMapConfig.xml解释配置说明
- ibatis之SqlMapConfig.xml配置详解
- ibatis SqlMapConfig.xml详细解释配置说明
- ibatis之SqlMapConfig.xml配置详解
- ibatis的sqlMapConfig.xml配置大全
- iBatis之SqlMapConfig.xml配置说明
- ibatis框架SqlMapConfig.xml文件配置
- Spring粘合iBatis时多种配置SqlMapConfig.xml路径的方法
- Ibatis sqlMapConfig.xml
- C++ 虚函数、多态性的演示 -- 虚拟析构函数
- 安装SQL Server 2005 Performance Dashboard Reports的技巧
- 托管cstring^ 转换为 std::string
- PHP大赛
- MCS-51中断系统
- Spring配置iBatis多个SqlMapConfig.xml
- String.Format的多格式定义
- 一个清华学生留学香港后对人生的思考
- 51单片机的定时/计数器
- 破解博思特软件
- 荣耀与梦想
- 从Clustering Factor说起
- 函数的DLL调用方式
- DevExpress.XtraTreeList.TreeList 控件如何找到当前被选中的节点