Ibatis的SqlMapConfig.xml按模块引入总的sql的xml如何引
在应用ibatis时,我们通常在SqlMapConfig.xml里面将用到的Sql配置文件全部一坨的全部引入,如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMapConfig PUBLIC "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-config-2.dtd">
<sqlMapConfig>
<!-- 引入JDBC连接池相关配置文件 -->
<properties resource="com/ibatis/config/jdbc.properties" />
<!-- 设置ibatis性能参数 -->
<settings
cacheModelsEnabled="true"
enhancementEnabled="true"
lazyLoadingEnabled="true"
maxRequests="100"
maxSessions="10"
maxTransactions="5"
useStatementNamespaces="false"
defaultStatementTimeout="5" />
<!-- 使用JDBC事务管理器,JDBC是已经定义好的别名 -->
<transactionManager type="JDBC">
<dataSource type="DBCP">
<property name="JDBC.Driver" value="${driverClassName}" />
<property name="JDBC.ConnectionURL" value="${url}" />
<property name="JDBC.Username" value="${username}" />
<property name="JDBC.Password" value="${password}" />
<property name="DefaultAutoCommit" value="true" />
<property name="Pool.MaximunActiveConnections" value="10" />
<property name="Pool.MaximunIdleConnections" value="5" />
<property name="Pool.MaximunCheckoutTime" value="12000" />
<property name="Pool.TimeToWait" value="500" />
<property name="Pool.PingQuery" value="select 1 from Books" />
<property name="Pool.PingEnabled" value="false" />
<property name="Pool.PingConnectionsOlderThan" value="1" />
<property name="Pool.PingConnectionsNotUsedFor" value="1" />
</dataSource>
</transactionManager>
<!-- 引入SQL配置文件,可以引入多个该文件 -->
<sqlMap resource="com/myproject/sql/mapper/Student1.xml" />
<sqlMap resource="com/myproject/sql/mapper/Student2.xml" />
<sqlMap resource="com/myproject/sql/mapper/Student3.xml" />
<sqlMap resource="com/myproject/sql/mapper/Student4.xml" />
<sqlMap resource="com/myproject/sql/mapper/Student5.xml" /> </sqlMapConfig>
如上图所示,现在不想这么做,要把student1.xml,student2.xml,student3.xml......作为一个模块放到一个总的student.xml里面进行引入,在总的student.xml里面再分别引入student1.xml,student2.xml,student3.xml......
求解答。。。,最好有范例
[解决办法]
它没有这么高级的设计,你可以自己写一个。