spring的多数据源配置(spring+ibatis + oracle环境下)


Mybatis技术学习,更多知识请访问https://www.itkc8.com

applicationContext.xml

 

 

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:aop="http://www.springframework.org/schema/aop"
	xmlns:tx="http://www.springframework.org/schema/tx"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
			http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
			http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"
	default-lazy-init="true" default-autowire="autodetect" default-merge="true" >
	<bean  id="configproperties"  class="org.springframework.beans.factory.config.PropertiesFactoryBean">
		<property name="location" value="classpath:config.properties" />
	</bean>
	<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
		<property name="properties" ref="configproperties" />
	</bean>
	<bean id="dataSourceFt" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
        <property name="driverClassName" value="oracle.jdbc.OracleDriver"/>
		<property name="url" value="${ORACLE.DATASOURCE.CORE.URL}"/>
        <property name="username" value="${ORACLE.DATASOURCE.CORE.USERNAME}"/>
        <property name="password" value="${ORACLE.DATASOURCE.CORE.PASSWORD}"/>  
        <property name="maxActive" value="50"/>
        <property name="minIdle" value="5"/>
        <property name="initialSize" value="10"/>
        <property name="maxWait" value="1000"/>
        <property name="poolPreparedStatements" value="false"/>
        <property name="defaultAutoCommit" value="true"/>
    </bean>
	<bean id="dataSourceBsk" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
        <property name="driverClassName" value="oracle.jdbc.OracleDriver"/>
		<property name="url" value="${ORACLE.DATASOURCE.CORE.URLBSK}"/>
        <property name="username" value="${ORACLE.DATASOURCE.CORE.USERNAMEBSK}"/>
        <property name="password" value="${ORACLE.DATASOURCE.CORE.PASSWORDBSK}"/>  
        <property name="maxActive" value="50"/>
        <property name="minIdle" value="5"/>
        <property name="initialSize" value="10"/>
        <property name="maxWait" value="1000"/>
        <property name="poolPreparedStatements" value="false"/>
        <property name="defaultAutoCommit" value="true"/>
    </bean>
    <bean id="sqlMapClientFt" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
		<property name="configLocation" value="classpath:IBatisCfg.xml" />
		<property name="dataSource" ref="dataSourceFt" />
	</bean>
    <bean id="sqlMapClientBsk" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
		<property name="configLocation" value="classpath:IBatisCfgBsk.xml" />
		<property name="dataSource" ref="dataSourceBsk" />
	</bean>
	<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
		<property name="dataSource" ref="dataSourceFt" />
	</bean>
	<bean id="transactionManagerBsk" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
		<property name="dataSource" ref="dataSourceBsk" />
	</bean>
	<tx:advice id="txAdvice" transaction-manager="transactionManager">
	    <tx:attributes>
	        <tx:method name="add*" propagation="REQUIRED"/>
	        <tx:method name="save*" propagation="REQUIRED"/>
	        <tx:method name="insert*" propagation="REQUIRED"/>
	        <tx:method name="update*" propagation="REQUIRED"/>
	        <tx:method name="delete*" propagation="REQUIRED"/>
	        <tx:method name="remove*" propagation="REQUIRED"/>
	        <tx:method name="get*" read-only="true" />
	        <tx:method name="select*" read-only="true" />
	        <tx:method name="find*" read-only="true" />
	        <tx:method name="*" read-only="true" />
	   </tx:attributes>
	</tx:advice>
	<aop:config >
    	<aop:advisor pointcut="execution(* com.hhly.platform.oss.service..*Service.*(..))" advice-ref="txAdvice"/>
	</aop:config>
	<tx:advice id="txAdviceBsk" transaction-manager="transactionManagerBsk">
	    <tx:attributes>
	        <tx:method name="add*" propagation="REQUIRED"/>
	        <tx:method name="save*" propagation="REQUIRED"/>
	        <tx:method name="insert*" propagation="REQUIRED"/>
	        <tx:method name="update*" propagation="REQUIRED"/>
	        <tx:method name="delete*" propagation="REQUIRED"/>
	        <tx:method name="remove*" propagation="REQUIRED"/>
	        <tx:method name="get*" read-only="true" />
	        <tx:method name="select*" read-only="true" />
	        <tx:method name="find*" read-only="true" />
	        <tx:method name="*" read-only="true" />
	   </tx:attributes>
	</tx:advice>
	<aop:config >
    	<aop:advisor pointcut="execution(* com.hhly.platform.oss.service..*Service.*(..))" advice-ref="txAdviceBsk"/>
	</aop:config>
	
	<import resource="classpath:spring/applicationContext-dao.xml"/>
	<import resource="classpath:spring/applicationContext-service.xml"/>
	<import resource="classpath:spring/applicationContext-job.xml"/>
	<import resource="classpath:spring/applicationContext-jms.xml"/>
	
	<bean id="connectionParam" class="com.hhly.platform.oss.zeroc.IceConnParam">
		<property name="clientCfgClassPath" value="config/zeroc/IceCfg.client"/>
		<property name="severUrl" value="${ICE.SERVER}"/>
		<property name="timeOut" value="120000"/>
		<property name="prxNames">
            <map>
            	<entry key="ice-ybf-web" value="com.hhly.ybf.football.ServicePrxHelper"/>
            </map>
        </property>
	</bean>
	<bean id="connectionParamBasket" class="com.hhly.platform.oss.zeroc.IceConnParam">
        <property name="clientCfgClassPath" value="config/zeroc/IceCfg.client"></property>
        <property name="severUrl" value="${ICE.BASKETBALL}"></property>
        <property name="timeOut" value="100000"></property>
        <property name="prxNames">
            <map>
                <entry key="mlottery_basket" value="com.sgfm.score.dao.basket.BasketDataPrxHelper"/>
            </map>
        </property>
    </bean> 
</beans>

 

 

 

 

 

applicationContext-dao.xml

 

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="
			http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
			http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
			http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd" default-lazy-init="true" default-autowire="autodetect" default-merge="true">
	<!-- 权限系统开始 -->
	<bean id="tblPopedomRelationDao" class="com.hhly.platform.oss.dao.impl.TblPopedomRelationDaoImpl" autowire="byName">
		<property name="sqlMapClient" ref="sqlMapClientFt" />
	</bean>
	<bean id="tblOssOperatePopedomDao" class="com.hhly.platform.oss.dao.impl.TblOssOperatePopedomDaoImpl" autowire="byName">
		<property name="sqlMapClient" ref="sqlMapClientFt" />
	</bean>
</beans>

 

 

Mybatis技术学习,更多知识请访问https://www.itkc8.com

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值