<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>WEB-INF/config/jdbc.properties </value>
</list>
</property>
</bean>
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName"
value="${jdbc.driverClassName}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
</bean>
<!-- 数据源的加载 -->
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<bean id="sqlMapClient"
class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="configLocation"
value="/WEB-INF/config/sqlMap-config.xml" />
<property name="dataSource" ref="dataSource" />
</bean>
DAO层是:
public class DepartmentDaoImp extends SqlMapClientDaoSupport implements
DepartmentDao {
public int addDepartment(DepartmentInfo departmentInfo) {
return getSqlMapClientTemplate().update("Department.addDepartment", departmentInfo);
}
当然可以配置多个,sqlMapClient只是默认的,你可以自己配置多个呀
<bean id="userDaoImp" class="gov.ynfda.dao.UserDaoImp">
<property name="sqlMapClient" ref="sqlMapClient" />
<property name="sqlMapClient1" ref="sqlMapClient" />
<property name="sqlMapClient2" ref="sqlMapClient2" />
<property name="sqlMapClient3" ref="sqlMapClient3" />
</bean>
transactionManager也分成多个
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<bean id="transactionManager1"......
<bean id="transactionManager2"......
然后再你的dao类里面声明(sqlMapClient是默认的无需声明)
private SqlMapClient sqlMapClient1;
private SqlMapClient sqlMapClient2;
private SqlMapClient sqlMapClient3;
get/set ......