ibatis使用及在spring中的bean配置
来源:互联网 发布:家用网络如何接交换机 编辑:程序博客网 时间:2024/06/05 00:10
package com.common;import com.ibatis.sqlmap.client.SqlMapClient;public interface MultiDBService { /** * 根据数据库名,获取对应的sqlclient * @param dbname * @return */ public SqlMapClient getClient(String dbname);}
package com.common;import java.util.Map;import com.ibatis.sqlmap.client.SqlMapClient;public final class MultiDBServiceImpl implements MultiDBService{ Map<String, SqlMapClient> clients; public SqlMapClient getClient(String dbname) { SqlMapClient ret = clients.get(dbname); return ret; } public Map<String, SqlMapClient> getClients() { return clients; } public void setClients(Map<String, SqlMapClient> clients) { this.clients = clients; }}
package com.common;public interface BaseService {}
package com.common;public class BaseServiceImpl implements BaseService{ public MultiDBService dbs; public MultiDBService getDbs() { return dbs; } public void setDbs(MultiDBService dbs) { this.dbs = dbs; }}
bean配置
<bean id="mydatasource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="com.mysql.jdbc.Driver" /> <property name="url" value="${url}" /> <property name="username" value="${username}" /> <property name="password" value="${password}" /> <property name="initialSize" value="16"/> <property name="maxActive" value="512"/> <property name="maxIdle" value="16"/> <property name="maxWait" value="3000"/> <property name="validationQuery" value="select COUNT(*) from DUAL"/> <property name="testWhileIdle" value="true"/> <property name="timeBetweenEvictionRunsMillis" value="10000"/> <property name="numTestsPerEvictionRun" value="5"/> <property name="logAbandoned" value="true"/> <property name="removeAbandoned" value="true"/> <property name="removeAbandonedTimeout" value="300"/> </bean> <bean id="mysqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean"> <property name="configLocation" value="WEB-INF/sqlmap-configs/db_config.xml"/> <property name="dataSource" ref="mydatasource"/> </bean> <bean id="dbs" class="com.common.MultiDBServiceImpl"> <property name="clients"> <map> <entry> <key><value>db_client</value></key> <ref bean="mysqlMapClient"/> </entry> </map> </property> </bean>
0 0
- ibatis使用及在spring中的bean配置
- Spring -- ApplicationContext使用及Bean的配置
- Spring -- ApplicationContext使用及Bean的配置
- Hibernate和ibatis在同一个webapp中混合使用在spring中的配置方法
- Spring 中的 Bean 配置
- Spring 中的 Bean 配置
- Spring中的Bean配置
- Spring中的Bean配置
- tomcat6中配置jndi及jndi在spring中的使用
- Spring Bean在XML配置中的父子继承
- ibatis中的SQLMapConfig.xml配置及.properties文件的使用
- Spring中的Bean配置说明
- 配置Spring Ioc中的bean
- 在Spring中使用iBatis
- Bean在spring中的作用!
- 在struts配置文件中使用spring配置的bean
- 继承关系 在spring的bean注入中的使用
- Spring 配置使用 - 装配 Bean
- 求图像的直方图这一大类
- androidStudio出现R无法识别比对下面build.gradule
- 你真的了解word-wrap和word-break的区别吗
- 美团推荐算法实践
- eclipse完美配置PHP开发环境
- ibatis使用及在spring中的bean配置
- 每天一篇python: pickle 模块篇
- Java中继承与代码块综合
- Python项目实战:个人博客(2):搭建orm框架
- .net接收表单的html标签报错从客户端(......)中检测到有潜在危险的 Request.Form 值
- Catch That Cow
- 论如何科学的看小本子
- Python实例2
- Linux环境搭建:2. 安装Ubuntu虚拟机